Fix possible memory leak in util/virxml.c

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>
This commit is contained in:
Pavel Hrdina 2014-01-13 15:06:03 +01:00
parent 788e6cb25b
commit 67fbf129fc

View File

@ -1047,6 +1047,8 @@ virXMLExtractNamespaceXML(xmlNodePtr root,
cleanup:
if (doc)
*doc = xmlstr;
else
VIR_FREE(xmlstr);
xmlFreeNode(nodeCopy);
return ret;
}