Fix memory leak in testDomainCreateXMLMixed()

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>
This commit is contained in:
Nehal J Wani 2014-01-14 18:40:53 +05:30 committed by Ján Tomko
parent 066c8ef6c1
commit b22f772610

View File

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