[Libguestfs] [PATCH 02/14] daemon: Fix memory leak in 'initrd-cat' (found by valgrind).

Richard W.M. Jones rjones at redhat.com
Tue Jan 24 17:02:16 UTC 2012


From: "Richard W.M. Jones" <rjones at redhat.com>

---
 daemon/initrd.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/daemon/initrd.c b/daemon/initrd.c
index 7c4d03f..d9c7050 100644
--- a/daemon/initrd.c
+++ b/daemon/initrd.c
@@ -108,9 +108,11 @@ do_initrd_cat (const char *path, const char *filename, size_t *size_r)
   int r = system (cmd);
   if (r == -1) {
     reply_with_perror ("command failed: %s", cmd);
+    free (cmd);
     rmdir (tmpdir);
     return NULL;
   }
+  free (cmd);
   if (WEXITSTATUS (r) != 0) {
     reply_with_perror ("command failed with return code %d",
                        WEXITSTATUS (r));
-- 
1.7.6




More information about the Libguestfs mailing list