From: Pavel Hrdina Date: Mon, 13 Jan 2014 14:06:03 +0000 (+0100) Subject: Fix possible memory leak in util/virxml.c X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=67fbf129fc8727c98f7c4123c12a48938ccdf3fa;p=libvirt.git 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 --- diff --git a/src/util/virxml.c b/src/util/virxml.c index 58523745cb..dd530a6927 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; }