[PATCH v2] malloc: fix memleak in function muntrace
Florian Weimer
fw@deneb.enyo.de
Tue Apr 21 09:11:24 GMT 2020
* Zack Weinberg:
> On Mon, Apr 20, 2020 at 12:19 PM Florian Weimer <fw@deneb.enyo.de> wrote:
>> * Zack Weinberg:
>> > On Mon, Apr 20, 2020 at 10:50 AM Florian Weimer <fw@deneb.enyo.de> wrote:
>> >> * chenzefeng:
>> >> > + if (malloc_trace_buffer != NULL)
>> >> > + free (malloc_trace_buffer);
>> >> > }
>> >>
>> >> I think you can call free unconditionally.
>> >
>> > I was going to say the same thing. (free(NULL) is specified to do nothing.)
>> >
>> > Also, it would be good to set malloc_trace_buffer to NULL after
>> > calling free.
>>
>> This introduces an asymmetry with the handling of f.
>
> f is a local variable. muntrace does set mallstream to NULL.
Oh in this case, malloc_trace_buffer should be reset as well.
More information about the Libc-alpha
mailing list