]> xenbits.xensource.com Git - libvirt.git/commitdiff
Resolve a couple of memory leaks
authorJohn Ferlan <jferlan@redhat.com>
Thu, 14 Apr 2016 14:21:27 +0000 (10:21 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Sat, 16 Apr 2016 12:04:14 +0000 (08:04 -0400)
Commit id '4b75237f' seems to have triggered Coverity into finding
at least one memory leak in xen_xl.c for error path for cleanup where
the listenAddr would be leaked. Reviewing other callers, it seems that
qemu_parse_command.c would have the same issue, so just it too.

src/qemu/qemu_parse_command.c
src/xenconfig/xen_xl.c

index 6fbb702b5b45f4c1d11798c0cb1d7a0fbea1b426..79f5b92aee3250a22fff5c6a4d7ac13f2d3a19be 100644 (file)
@@ -500,6 +500,7 @@ qemuParseCommandLineVnc(virDomainDefPtr def,
 {
     int ret = -1;
     virDomainGraphicsDefPtr vnc = NULL;
+    char *listenAddr = NULL;
     char *tmp;
 
     if (VIR_ALLOC(vnc) < 0)
@@ -519,7 +520,6 @@ qemuParseCommandLineVnc(virDomainDefPtr def,
         char *opts;
         char *port;
         const char *sep = ":";
-        char *listenAddr = NULL;
         if (val[0] == '[')
             sep = "]:";
         tmp = strstr(val, sep);
@@ -614,6 +614,7 @@ qemuParseCommandLineVnc(virDomainDefPtr def,
 
  cleanup:
     virDomainGraphicsDefFree(vnc);
+    VIR_FREE(listenAddr);
     return ret;
 }
 
index b5d4da1928ea75a0b3f844b30acb493b2070a372..889dd400fcd7cbfe4890875a46bd02586ae9d21c 100644 (file)
@@ -240,6 +240,7 @@ xenParseXLSpice(virConfPtr conf, virDomainDefPtr def)
     return 0;
 
  cleanup:
+    VIR_FREE(listenAddr);
     virDomainGraphicsDefFree(graphics);
     return -1;
 }