[libvirt] [PATCH] Fix Memory Leak in daemon/libvirtd.c

Nehal J Wani nehaljw.kkd1 at gmail.com
Thu Apr 3 18:13:38 UTC 2014


Fixes leak introduced by e562e82f

==4937== 64 bytes in 1 blocks are definitely lost in loss record 270 of 405
==4937==    at 0x4A06BE0: realloc (vg_replace_malloc.c:662)
==4937==    by 0x6FA41C4: __vasprintf_chk (vasprintf_chk.c:90)
==4937==    by 0x50C8D29: virVasprintfInternal (stdio2.h:199)
==4937==    by 0x50C8E3A: virAsprintfInternal (virstring.c:362)
==4937==    by 0x11D01A: main (libvirtd.c:1170)

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

diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index e247259..bb84c90 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -1132,6 +1132,7 @@ int main(int argc, char **argv) {
     bool privileged = geteuid() == 0 ? true : false;
     bool implicit_conf = false;
     char *run_dir = NULL;
+    char *cpumap = NULL;
     mode_t old_umask;
 
     struct option opts[] = {
@@ -1159,7 +1160,6 @@ int main(int argc, char **argv) {
     if (strstr(argv[0], "lt-libvirtd") ||
         strstr(argv[0], "/daemon/.libs/libvirtd")) {
         char *tmp = strrchr(argv[0], '/');
-        char *cpumap;
         if (!tmp) {
             fprintf(stderr, _("%s: cannot identify driver directory\n"), argv[0]);
             exit(EXIT_FAILURE);
@@ -1182,6 +1182,7 @@ int main(int argc, char **argv) {
         virDriverModuleInitialize(driverdir);
 #endif
         cpuMapOverride(cpumap);
+        VIR_FREE(cpumap);
         *tmp = '/';
         /* Must not free 'driverdir' - it is still used */
     }
-- 
1.7.1




More information about the libvir-list mailing list