]> xenbits.xensource.com Git - libvirt.git/commitdiff
Fix possible memory leak in util/virxml.c
authorPavel Hrdina <phrdina@redhat.com>
Mon, 13 Jan 2014 14:06:03 +0000 (15:06 +0100)
committerPavel Hrdina <phrdina@redhat.com>
Wed, 15 Jan 2014 10:11:34 +0000 (11:11 +0100)
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@redhat.com>
src/util/virxml.c

index 58523745cb6a114a3fcdbfa60a1431169c672861..dd530a69270773ab141104c8997cc4acf0c59e58 100644 (file)
@@ -1047,6 +1047,8 @@ virXMLExtractNamespaceXML(xmlNodePtr root,
 cleanup:
     if (doc)
         *doc = xmlstr;
+    else
+        VIR_FREE(xmlstr);
     xmlFreeNode(nodeCopy);
     return ret;
 }