[PATCH 2/2] conf: Fix leaks in virNetworkObjUpdateParseFile

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Free the bitmap before calling virBitmapParse, which will overwrite it.

Also free xml.
---
 src/conf/network_conf.c |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index c93916d..013333c 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -1855,14 +1855,16 @@ virNetworkObjUpdateParseFile(const char *filename,
 
         ctxt->node = node;
         class_id = virXPathString("string(./class_id[1]/@bitmap)", ctxt);
-        if (class_id &&
-            virBitmapParse(class_id, 0,
-                           &net->class_id, CLASS_ID_BITMAP_SIZE) < 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("Malformed 'class_id' attribute: %s"),
-                           class_id);
-            VIR_FREE(class_id);
-            goto cleanup;
+        if (class_id) {
+            virBitmapFree(net->class_id);
+            if (virBitmapParse(class_id, 0,
+                               &net->class_id, CLASS_ID_BITMAP_SIZE) < 0) {
+                virReportError(VIR_ERR_INTERNAL_ERROR,
+                               _("Malformed 'class_id' attribute: %s"),
+                               class_id);
+                VIR_FREE(class_id);
+                goto cleanup;
+            }
         }
         VIR_FREE(class_id);
 
@@ -1896,6 +1898,7 @@ virNetworkObjUpdateParseFile(const char *filename,
 
 cleanup:
     xmlXPathFreeContext(ctxt);
+    xmlFreeDoc(xml);
     return ret;
 }
 
-- 
1.7.8.6

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]