[vlc-devel] [PATCH 2/2] compat: tfind: fix a leak in tdelete

Rémi Denis-Courmont remi at remlab.net
Thu Apr 1 13:49:06 UTC 2021


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?

> ---
>  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/





More information about the vlc-devel mailing list