From a26ded37a2e5d1deaa34fcc83d8cc6c4067ad040 Mon Sep 17 00:00:00 2001
Message-Id: <a26ded37a2e5d1deaa34fcc83d8cc6c4067ad040@dist-git>
From: Pavel Hrdina <phrdina@redhat.com>
Date: Thu, 22 Jan 2015 15:53:56 +0100
Subject: [PATCH] Fix possible memory leak in util/virxml.c
https://bugzilla.redhat.com/show_bug.cgi?id=1184929
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>
(cherry picked from commit 67fbf129fc8727c98f7c4123c12a48938ccdf3fa)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
src/util/virxml.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/util/virxml.c b/src/util/virxml.c
index de1e1e0..88a1196 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;
}
--
2.2.1