[Libvirt-cim] [PATCH 3/4] xml_parse_test: Fix invalid dereference

Eduardo Lima (Etrunko) eblima at linux.vnet.ibm.com
Wed Jan 18 16:06:11 UTC 2012


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

As revealed by recent Coverity scan report provided by Red Hat:
https://bugzilla.redhat.com/show_bug.cgi?id=750418
https://bugzilla.redhat.com/attachment.cgi?id=552325

Error: USE_AFTER_FREE:
xml_parse_test.c:239: freed_arg: "free" frees "xml".
xml_parse_test.c:242: pass_freed_arg: Passing freed pointer "xml" as an argument to function "printf".

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

diff --git a/libxkutil/xml_parse_test.c b/libxkutil/xml_parse_test.c
index 16ceefb..384593d 100644
--- a/libxkutil/xml_parse_test.c
+++ b/libxkutil/xml_parse_test.c
@@ -236,11 +236,10 @@ static int dominfo_from_file(const char *fname, struct domain **d)
 
         ret = get_dominfo_from_xml(xml, d);
 
+        printf("XML:\n%s", xml);
         free(xml);
         fclose(file);
 
-        printf("XML:\n%s", xml);
-
         return ret;
 }
 
-- 
1.7.7.5




More information about the Libvirt-cim mailing list