[libvirt] [PATCH 3/3] Resolve a couple of memory leaks

John Ferlan jferlan at redhat.com
Thu Apr 14 14:42:32 UTC 2016


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.

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 src/qemu/qemu_parse_command.c | 3 ++-
 src/xenconfig/xen_xl.c        | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c
index 6fbb702..79f5b92 100644
--- a/src/qemu/qemu_parse_command.c
+++ b/src/qemu/qemu_parse_command.c
@@ -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;
 }
 
diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c
index b5d4da1..889dd40 100644
--- a/src/xenconfig/xen_xl.c
+++ b/src/xenconfig/xen_xl.c
@@ -240,6 +240,7 @@ xenParseXLSpice(virConfPtr conf, virDomainDefPtr def)
     return 0;
 
  cleanup:
+    VIR_FREE(listenAddr);
     virDomainGraphicsDefFree(graphics);
     return -1;
 }
-- 
2.5.5




More information about the libvir-list mailing list