]> xenbits.xensource.com Git - libvirt.git/commitdiff
Fix small memory leaks in config parsing related functions
authorMatthias Bolte <matthias.bolte@googlemail.com>
Sun, 24 Apr 2011 18:00:30 +0000 (20:00 +0200)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Mon, 25 Apr 2011 17:08:53 +0000 (19:08 +0200)
Found by 'make -C tests valgrind'.

xen_xm.c: Dummy allocation via virDomainChrDefNew is directly
overwritten and lost. Free 'script' in success path too.

vmx.c: Free virtualDev_string in success path too.

domain_conf.c: Free compression in success path too.

src/conf/domain_conf.c
src/vmx/vmx.c
src/xenxs/xen_xm.c

index 381e6924e54536cd0d415b7c12b0913d195cd006..0e7aeb587a1b1751bd98e12363dea38173f43aca 100644 (file)
@@ -4058,6 +4058,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, int flags) {
                         VIR_FREE(compression);
                         goto error;
                     }
+                    VIR_FREE(compression);
 
                     def->data.spice.zlib = compressionVal;
                 } else if (xmlStrEqual(cur->name, BAD_CAST "playback")) {
index daeedc31546d1e241e7b9c2696c7decfc2c0fd79..aee2d80459b03f8238e947a5861572078a518877 100644 (file)
@@ -1818,6 +1818,7 @@ int
 virVMXParseSCSIController(virConfPtr conf, int controller, bool *present,
                           int *virtualDev)
 {
+    int result = -1;
     char present_name[32];
     char virtualDev_name[32];
     char *virtualDev_string = NULL;
@@ -1840,16 +1841,17 @@ virVMXParseSCSIController(virConfPtr conf, int controller, bool *present,
              controller);
 
     if (virVMXGetConfigBoolean(conf, present_name, present, false, true) < 0) {
-        goto failure;
+        goto cleanup;
     }
 
     if (! *present) {
-        return 0;
+        result = 0;
+        goto cleanup;
     }
 
     if (virVMXGetConfigString(conf, virtualDev_name, &virtualDev_string,
                               true) < 0) {
-        goto failure;
+        goto cleanup;
     }
 
     if (virtualDev_string != NULL) {
@@ -1870,16 +1872,16 @@ virVMXParseSCSIController(virConfPtr conf, int controller, bool *present,
                       _("Expecting VMX entry '%s' to be 'buslogic' or 'lsilogic' "
                         "or 'lsisas1068' or 'pvscsi' but found '%s'"),
                        virtualDev_name, virtualDev_string);
-            goto failure;
+            goto cleanup;
         }
     }
 
-    return 0;
+    result = 0;
 
-  failure:
+  cleanup:
     VIR_FREE(virtualDev_string);
 
-    return -1;
+    return result;
 }
 
 
index dbcaf154ea7fe92085b4a492ef407c87e6ee3384..63ba153f4c5613edb2e67496e87f2f4f5d2f9363 100644 (file)
@@ -983,8 +983,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
                     continue;
                 }
 
-                if (!(chr = virDomainChrDefNew()))
-                    goto cleanup;
                 if (!(chr = xenParseSxprChar(port, NULL)))
                     goto cleanup;
 
@@ -1034,6 +1032,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
             goto cleanup;
     }
 
+    VIR_FREE(script);
     return def;
 
 no_memory: