Re: [PATCH] Fixup: perf bench: Fix two memory leaks detected with ASan

From: Ahmad Fatoum
Date: Sat Nov 20 2021 - 02:10:43 EST


On 20.11.21 07:53, Ahmad Fatoum wrote:
>> + snd_ctx_arr[total_counter] = snd_ctx;
>
> You are storing at snd_ctx_arr[num_fd] each time, so you will leak
> all context, except for the last one.

Oh, it's more subtle than that. total_counter is of course incremented
every time in the previous loop, so you will have num_fd times NULL
(from static initialization) then a pointer to an allocation and so on.
That works by the looks of it, but looks quite strange.


--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |