qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] tests: fix a memory in test_socket_unix_abstract_good


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH] tests: fix a memory in test_socket_unix_abstract_good
Date: Wed, 3 Jun 2020 19:25:59 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0

On 6/3/20 6:14 PM, Li Qiang wrote:
> After build qemu with '-fsanitize=address' extra-cflags,
> 'make check' show following leak:
> 
> =================================================================
> ==44580==ERROR: LeakSanitizer: detected memory leaks
> 
> Direct leak of 2500 byte(s) in 1 object(s) allocated from:
>     #0 0x7f1b5a8b8d28 in __interceptor_calloc 
> (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
>     #1 0x7f1b5a514b10 in g_malloc0 
> (/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x51b10)
>     #2 0xd79ea4e4c0ad31c3  (<unknown module>)
> 
> SUMMARY: AddressSanitizer: 2500 byte(s) leaked in 1 allocation(s).
> 
> Call 'g_rand_free' in the end of function to avoid this.

GLib doc doesn't seem complete (they don't mention explicitly the
generator returned from g_rand_new has to be released with g_rand_free).

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> 
> Fixes: 4d3a329af59("tests/util-sockets: add abstract unix socket cases")
> Signed-off-by: Li Qiang <liq3ea@163.com>
> ---
>  tests/test-util-sockets.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tests/test-util-sockets.c b/tests/test-util-sockets.c
> index 2ca1e99f17..ca6671f9bf 100644
> --- a/tests/test-util-sockets.c
> +++ b/tests/test-util-sockets.c
> @@ -312,6 +312,7 @@ static void test_socket_unix_abstract_good(void)
>      g_thread_join(serv);
>  
>      g_free(abstract_sock_name);
> +    g_rand_free(r);
>  }
>  #endif
>  
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]