[vlc-devel] [PATCH 2/2] compat: tfind: fix a leak in tdelete
Steve Lhomme
robux4 at ycbcr.xyz
Thu Apr 1 15:26:44 UTC 2021
On 2021-04-01 17:19, Alexandre Janniaux wrote:
> Hi,
>
> On Thu, Apr 01, 2021 at 04:57:44PM +0200, Steve Lhomme wrote:
>> On 2021-04-01 15:49, Rémi Denis-Courmont wrote:
>>> Le torstaina 1. huhtikuuta 2021, 13.35.00 EEST Steve Lhomme a écrit :
>>>> In some case the root is reset to NULL (no more elements in the tree) but
>>>> the root pointer that was allocated in the first tsearch call is not freed
>>>> in that case.
>>>
>>> What is the upstream status if this alleged bug?
>>
>> I did not find the source of this code.
>>
>
> For the sources:
>
> https://github.com/NetBSD/src/blob/4618257c9b66cbfb216387cd3d0740f2b1b70750/lib/libc/stdlib/tfind.c
> https://github.com/NetBSD/src/blob/4618257c9b66cbfb216387cd3d0740f2b1b70750/lib/libc/stdlib/tdelete.c
>
> You can download NetBSD sources and get the file at the same
> path if you don´t want to trust github. ;)
I did find mention of a leak with that guy in the thread but I never
found the solution nor if it was in fact the same code base (netbsd =
System V?).
I'll grab the latest one and see if it solves the issue.
Thanks.
> Regards,
> --
> Alexandre Janniaux
> Videolabs
>
>>>> ---
>>>> compat/tfind.c | 2 ++
>>>> 1 file changed, 2 insertions(+)
>>>>
>>>> diff --git a/compat/tfind.c b/compat/tfind.c
>>>> index 03382f2aea5..cbb191db2f1 100644
>>>> --- a/compat/tfind.c
>>>> +++ b/compat/tfind.c
>>>> @@ -69,6 +69,8 @@ tdelete(const void* vkey, void** vrootp, int
>>>> (*compar)(const void*, const void*) }
>>>> if (p != *rootp)
>>>> free(*rootp); /* D4: Free node */
>>>> + else if (q == NULL)
>>>> + free(*rootp); /* don't leak before
>>> reset */
>>>> *rootp = q; /* link parent to
>>> new node */
>>>> return p;
>>>> }
>>>
>>>
>>> --
>>> Rémi Denis-Courmont
>>> http://www.remlab.net/
>>>
>>>
>>>
>>> _______________________________________________
>>> vlc-devel mailing list
>>> To unsubscribe or modify your subscription options:
>>> https://mailman.videolan.org/listinfo/vlc-devel
>>>
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
>
More information about the vlc-devel
mailing list