[Libvirt-cim] [PATCH 8/8] xmlgen: Avoid double-free

Eduardo Lima (Etrunko) eblima at linux.vnet.ibm.com
Thu Nov 3 17:48:36 UTC 2011


From: Eduardo Lima (Etrunko) <eblima at br.ibm.com>

As revealed by Coverity scan report:

https://bugzilla.redhat.com/show_bug.cgi?id=728245#c8
https://bugzilla.redhat.com/attachment.cgi?id=530435

Error: USE_AFTER_FREE:
xmlgen.c:1271: freed_arg: "free" frees "string".
xmlgen.c:1317: double_free: Calling "free" frees pointer "string" which has
                            already been freed.

Error: USE_AFTER_FREE:
xmlgen.c:1288: freed_arg: "free" frees "string".
xmlgen.c:1317: double_free: Calling "free" frees pointer "string" which has
                            already been freed.

Signed-off-by: Eduardo Lima (Etrunko) <eblima at br.ibm.com>
---
 libxkutil/xmlgen.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c
index ee20895..4cca75b 100644
--- a/libxkutil/xmlgen.c
+++ b/libxkutil/xmlgen.c
@@ -1292,6 +1292,7 @@ static const char *storage_vol_xml(xmlNodePtr root,
                 goto out;
 
         free(string);
+        string = NULL;
 
         if (vol->cap_units != NULL) {
                 xmlAttrPtr tmp = NULL;
@@ -1309,6 +1310,7 @@ static const char *storage_vol_xml(xmlNodePtr root,
                 goto out;
 
         free(string);
+        string = NULL;
 
         if (vol->cap_units != NULL) {
                 xmlAttrPtr tmp = NULL;
-- 
1.7.4.4




More information about the Libvirt-cim mailing list