[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] Fix memory leak in testDomainCreateXMLMixed()



On 01/14/2014 02:10 PM, Nehal J Wani wrote:
> While running objecteventtest, it was found that valgrind pointed out the
> following memory leak:
> 
> ==13025== 538 (56 direct, 482 indirect) bytes in 1 blocks are definitely lost in loss record 216 of 226
> ==13025==    at 0x4A06B6F: calloc (vg_replace_malloc.c:593)
>     ==13025==    by 0x4C65D8D: virAllocVar (viralloc.c:558)
>     ==13025==    by 0x4C9F055: virObjectNew (virobject.c:190)
>     ==13025==    by 0x4D2B2E8: virGetDomain (datatypes.c:220)
>     ==13025==    by 0x4D79180: testDomainDefineXML (test_driver.c:2962)
>     ==13025==    by 0x4D4977D: virDomainDefineXML (libvirt.c:8512)
>     ==13025==    by 0x4029C2: testDomainCreateXMLMixed (objecteventtest.c:226)
>     ==13025==    by 0x403A21: virtTestRun (testutils.c:138)
>     ==13025==    by 0x4021C2: mymain (objecteventtest.c:549)
>     ==13025==    by 0x4040C2: virtTestMain (testutils.c:593)
>     ==13025==    by 0x341F421A04: (below main) (libc-start.c:225)
>     ==13025==
> 
> ---
>  tests/objecteventtest.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/tests/objecteventtest.c b/tests/objecteventtest.c
> index 65642a2..de57970 100644
> --- a/tests/objecteventtest.c
> +++ b/tests/objecteventtest.c
> @@ -245,6 +245,12 @@ testDomainCreateXMLMixed(const void *data)
>      if (id2 < 0)
>          goto cleanup;
>  
> +    if (dom != NULL) {
> +        virDomainUndefine(dom);
> +        virDomainDestroy(dom);
> +        virDomainFree(dom);
> +    }
> +

dom has to be non-NULL here.

ACK and pushed now with the condition removed.

Jan


Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]