Re: [PATCH] Fix Memory Leak in testMessageArrayRef()

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

 



On 03/30/2014 03:35 PM, Nehal J Wani wrote:
> While running virdbustest, it was found that valgrind pointed out
> the following memory leaks:
> 
> ==9996== 17 (8 direct, 9 indirect) bytes in 1 blocks are definitely lost in loss record 9 of 36
> ==9996==    at 0x4A069EE: malloc (vg_replace_malloc.c:270)
> ==9996==    by 0x4A06B62: realloc (vg_replace_malloc.c:662)
> ==9996==    by 0x4C6B587: virReallocN (viralloc.c:245)
> ==9996==    by 0x4C6B6AE: virExpandN (viralloc.c:294)
> ==9996==    by 0x4C82B54: virDBusMessageDecodeArgs (virdbus.c:907)

> +++ b/tests/virdbustest.c
> @@ -250,6 +250,7 @@ static int testMessageArrayRef(const void *args ATTRIBUTE_UNUSED)
>      size_t out_nstrv2 = 0;
>      const char *in_str2 = "World";
>      char *out_str1 = NULL, *out_str2 = NULL;
> +    size_t i = 0;

No need to initialize this to 0; it never gets used uninitialized.

>  
>      if (!(msg = dbus_message_new_method_call("org.libvirt.test",
>                                               "/org/libvirt/test",
> @@ -315,6 +316,12 @@ static int testMessageArrayRef(const void *args ATTRIBUTE_UNUSED)
>      VIR_FREE(out_int32);
>      VIR_FREE(out_str1);
>      VIR_FREE(out_str2);
> +    for (i = 0; i < out_nstrv1; i++)
> +        VIR_FREE(out_strv1[i]);
> +    VIR_FREE(out_strv1);
> +    for (i = 0; i < out_nstrv2; i++)
> +        VIR_FREE(out_strv2[i]);
> +    VIR_FREE(out_strv2);

ACK and pushed.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]