From 7c2ff55613598a1295e213cef36600ad61da7ed6 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 10 Jan 2012 16:55:49 +0100 Subject: helper: plug two small leaks * helper/ext2initrd.c (read_module_deps): Don't leak filename. (ext2_make_initrd): Don't leak "outfile". * helper/utils.c (load_file): Don't leak a file pointer. --- helper/ext2initrd.c | 4 +++- helper/utils.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/helper/ext2initrd.c b/helper/ext2initrd.c index dedc1e8..8b64e0f 100644 --- a/helper/ext2initrd.c +++ b/helper/ext2initrd.c @@ -1,5 +1,5 @@ /* febootstrap-supermin-helper reimplementation in C. - * Copyright (C) 2009-2011 Red Hat Inc. + * Copyright (C) 2009-2012 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -115,6 +115,7 @@ ext2_make_initrd (const char *modpath, const char *initrd) FILE *f = fopen (outfile, "w"); if (f == NULL) error (EXIT_FAILURE, errno, "failed to create modules list (%s)", outfile); + free (outfile); FILE *pp = popen (cmd, "w"); if (pp == NULL) error (EXIT_FAILURE, errno, "failed to create pipe (%s)", cmd); @@ -175,6 +176,7 @@ read_module_deps (const char *modpath) char *filename = xasprintf ("%s/modules.dep", modpath); FILE *fp = fopen (filename, "r"); + free (filename); if (fp == NULL) error (EXIT_FAILURE, errno, "open: %s/modules.dep", modpath); diff --git a/helper/utils.c b/helper/utils.c index 81b300a..3308c3c 100644 --- a/helper/utils.c +++ b/helper/utils.c @@ -1,5 +1,5 @@ /* febootstrap-supermin-helper reimplementation in C. - * Copyright (C) 2009-2010 Red Hat Inc. + * Copyright (C) 2009-2010, 2012 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -306,6 +306,7 @@ load_file (const char *filename) line[len-1] = '\0'; add_string (&lines, &n_used, &n_alloc, line); } + fclose (fp); add_string (&lines, &n_used, &n_alloc, NULL); return lines; -- cgit