summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2012-01-10 16:55:49 +0100
committerJim Meyering <meyering@redhat.com>2012-01-10 16:59:02 +0100
commit7c2ff55613598a1295e213cef36600ad61da7ed6 (patch)
treed843a109139f0a8ec0666ef08d7b41766d001329
parentfc904d83655bda4abfc9011b1e5723470f7ae326 (diff)
downloadfebootstrap-7c2ff55613598a1295e213cef36600ad61da7ed6.tar.gz
febootstrap-7c2ff55613598a1295e213cef36600ad61da7ed6.tar.xz
febootstrap-7c2ff55613598a1295e213cef36600ad61da7ed6.zip
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.
-rw-r--r--helper/ext2initrd.c4
-rw-r--r--helper/utils.c3
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;