]> xenbits.xensource.com Git - libvirt.git/commitdiff
Fix memory leak in __virExec
authorMatthias Bolte <matthias.bolte@googlemail.com>
Sat, 30 Apr 2011 10:06:29 +0000 (12:06 +0200)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Sat, 30 Apr 2011 15:37:29 +0000 (17:37 +0200)
Commit e0d014f2379dd made binary potentially allocated on the heap.
It was freed in the parent in the error path, but not in the success path
that doesn't goto the cleanup label.

Found by 'make -C tests valgrind'.

src/util/util.c

index c337aa9ef8e287f8fbb756ced71a8953dec866e8..37472bb8a55af9a30cba5acc7b68d2a02c970ab1 100644 (file)
@@ -568,6 +568,10 @@ __virExec(const char *const*argv,
         }
 
         *retpid = pid;
+
+        if (binary != argv[0])
+            VIR_FREE(binary);
+
         return 0;
     }