]> xenbits.xensource.com Git - libvirt.git/commitdiff
src: fix multiple resource leaks in loops
authorPavel Hrdina <phrdina@redhat.com>
Sun, 9 Apr 2017 10:49:24 +0000 (12:49 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Tue, 11 Apr 2017 11:23:00 +0000 (13:23 +0200)
All of the variables are filled inside a loop and therefore
needs to be also freed in every cycle.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
src/conf/node_device_conf.c
src/conf/storage_conf.c
src/util/virsysinfo.c

index 7d0baa9d1a7131e53a505045db1b54b53a7937df..330d5d92c5f909f5364f1a969261581319854339 100644 (file)
@@ -1582,7 +1582,6 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt,
     for (i = 0, m = 0; i < n; i++) {
         xmlNodePtr node = nodes[i];
         char *tmp = virXMLPropString(node, "type");
-        virNodeDevDevnodeType type;
         int val;
 
         if (!tmp) {
@@ -1591,15 +1590,17 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt,
             goto error;
         }
 
-        if ((val = virNodeDevDevnodeTypeFromString(tmp)) < 0) {
+        val = virNodeDevDevnodeTypeFromString(tmp);
+
+        if (val < 0) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("unknown devnode type '%s'"), tmp);
             VIR_FREE(tmp);
             goto error;
         }
-        type = val;
+        VIR_FREE(tmp);
 
-        switch (type) {
+        switch ((virNodeDevDevnodeType)val) {
         case VIR_NODE_DEV_DEVNODE_DEV:
             def->devnode = (char*)xmlNodeGetContent(node);
             break;
index fe0f0bcdc7f7dd6f3ea4d65011225843733bb5a9..b66e67254ac41206622ccba05879616ccaff02e8 100644 (file)
@@ -471,6 +471,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
                                    port);
                     goto cleanup;
                 }
+                VIR_FREE(port);
             }
         }
     }
index 8d3377c04e6b649489c85bc7585273cbbd3b9814..650216d006d6f771c1449f9c1753cf56b3417584 100644 (file)
@@ -521,6 +521,8 @@ virSysinfoParseS390Processor(const char *base, virSysinfoDefPtr ret)
                                           &processor->processor_family,
                                           '=', '\n'))
             goto cleanup;
+
+        VIR_FREE(procline);
     }
     result = 0;