]> xenbits.xensource.com Git - libvirt.git/commitdiff
Fix memory leak in testDomainCreateXMLMixed()
authorNehal J Wani <nehaljw.kkd1@gmail.com>
Tue, 14 Jan 2014 13:10:53 +0000 (18:40 +0530)
committerJán Tomko <jtomko@redhat.com>
Tue, 14 Jan 2014 13:49:07 +0000 (14:49 +0100)
While running objecteventtest, it was found that valgrind pointed out the
following memory leak:

==125== 538 (56 direct, 482 indirect) bytes in 1 blocks are definitely lost in loss record 216 of 226
==125==    at 0x4A06B6F: calloc (vg_replace_malloc.c:593)
==125==    by 0x4C65D8D: virAllocVar (viralloc.c:558)
==125==    by 0x4C9F055: virObjectNew (virobject.c:190)
==125==    by 0x4D2B2E8: virGetDomain (datatypes.c:220)
==125==    by 0x4D79180: testDomainDefineXML (test_driver.c:2962)
==125==    by 0x4D4977D: virDomainDefineXML (libvirt.c:8512)
==125==    by 0x4029C2: testDomainCreateXMLMixed (objecteventtest.c:226)
==125==    by 0x403A21: virtTestRun (testutils.c:138)
==125==    by 0x4021C2: mymain (objecteventtest.c:549)
==125==    by 0x4040C2: virtTestMain (testutils.c:593)
==125==    by 0x341F421A04: (below main) (libc-start.c:225)

Signed-off-by: Ján Tomko <jtomko@redhat.com>
tests/objecteventtest.c

index 65642a24595954e1565663944b1044cc23fce0b6..76dc378561136b9c07505a94c824a8ca342a7114 100644 (file)
@@ -245,6 +245,10 @@ testDomainCreateXMLMixed(const void *data)
     if (id2 < 0)
         goto cleanup;
 
+    virDomainUndefine(dom);
+    virDomainDestroy(dom);
+    virDomainFree(dom);
+
     dom = virDomainCreateXML(test->conn, domainDef, 0);
     if (dom == NULL || virEventRunDefaultImpl() < 0)
         goto cleanup;