[libvirt] [PATCH] Fix memory leak in virDomainChrSourceDefClear()

Nehal J Wani nehaljw.kkd1 at gmail.com
Tue Mar 18 07:32:24 UTC 2014


While running qemuxml2xmltest, it was found that valgrind pointed out
the following memory leak:

==21905== 26 bytes in 1 blocks are definitely lost in loss record 23 of 69
==21905==    at 0x4A069EE: malloc (vg_replace_malloc.c:270)
==21905==    by 0x3E782A754D: xmlStrndup (in /usr/lib64/libxml2.so.2.7.6)
==21905==    by 0x4CD986D: virDomainChrSourceDefParseXML (domain_conf.c:7233)
==21905==    by 0x4CE4199: virDomainChrDefParseXML (domain_conf.c:7512)
==21905==    by 0x4CFAF3F: virDomainDefParseXML (domain_conf.c:12303)
==21905==    by 0x4CFB46E: virDomainDefParseNode (domain_conf.c:13031)
==21905==    by 0x4CFB5E9: virDomainDefParse (domain_conf.c:12973)
==21905==    by 0x41E9D8: testCompareXMLToXMLFiles (qemuxml2xmltest.c:40)
==21905==    by 0x41EBAA: testCompareXMLToXMLHelper (qemuxml2xmltest.c:93)
==21905==    by 0x421D21: virtTestRun (testutils.c:199)
==21905==    by 0x41FCE9: mymain.part.0 (qemuxml2xmltest.c:244)
==21905==    by 0x42249D: virtTestMain (testutils.c:782)
==21905==
... and 7 more

---
 The leaks were specific to the tests:
 DO_TEST("serial-spiceport");
 DO_TEST("serial-spiceport-nospice");

 src/conf/domain_conf.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 92b1324..f633db7 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1495,6 +1495,10 @@ virDomainChrSourceDefClear(virDomainChrSourceDefPtr def)
     case VIR_DOMAIN_CHR_TYPE_UNIX:
         VIR_FREE(def->data.nix.path);
         break;
+
+    case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
+        VIR_FREE(def->data.spiceport.channel);
+        break;
     }
 }
 
-- 
1.7.1




More information about the libvir-list mailing list