[PATCH 3/6] Fix possible memory leak in util/virxml.c

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

 



A "xmlstr" string may not be assigned into a "doc" pointer and it
could cause memory leak. To fix it if the "doc" pointer is NULL and
the "xmlstr" string is not assigned we should free it.

This has been found by coverity.

Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 src/util/virxml.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/util/virxml.c b/src/util/virxml.c
index 5852374..dd530a6 100644
--- a/src/util/virxml.c
+++ b/src/util/virxml.c
@@ -1047,6 +1047,8 @@ virXMLExtractNamespaceXML(xmlNodePtr root,
 cleanup:
     if (doc)
         *doc = xmlstr;
+    else
+        VIR_FREE(xmlstr);
     xmlFreeNode(nodeCopy);
     return ret;
 }
-- 
1.8.3.1

--
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]