[vlc-devel] [PATCH 8/8] video_output/xcb: fix memory-leak in ReleaseDrawable

Thomas Guillem thomas at gllm.fr
Fri Sep 23 15:52:48 CEST 2016



On Fri, Sep 23, 2016, at 15:43, Filip Roséen wrote:
> The problem with the previous implementation is that "n" will never
> be equal to 0 at the relevant part of the code (given the
> unconditional pre-increment a few lines earlier).
> 
> These changes fixes the issue by freeing the allocated memory if the
> first element of "used" is NULL (meaning that there are no more
> entities referred to by it).
> 
> fixes #17112
> fixes #17293
> ---
>  modules/video_output/xcb/window.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/modules/video_output/xcb/window.c
> b/modules/video_output/xcb/window.c
> index 02c9dd1..63815af 100644
> --- a/modules/video_output/xcb/window.c
> +++ b/modules/video_output/xcb/window.c
> @@ -538,12 +538,15 @@ static void ReleaseDrawable (vlc_object_t *obj,
> xcb_window_t window)
>          used[n] = used[n + 1];
>      while (used[++n]);
>  
> -    if (n == 0)
> -         var_SetAddress (obj->obj.libvlc, "xid-in-use", NULL);
> +    if (used[0] == NULL)

Warning here:

../../modules/video_output/xcb/window.c: In function ‘ReleaseDrawable’:
../../modules/video_output/xcb/window.c:541:17: warning: comparison
between pointer and integer
    if (used[0] == NULL)

> +        var_SetAddress (obj->obj.libvlc, "xid-in-use", NULL);
> +    else
> +        used = NULL;
> +
>      vlc_mutex_unlock (&serializer);
>  
> -    if (n == 0)
> -        free (used);
> +    free( used );
> +
>      /* Variables are reference-counted... */
>      var_Destroy (obj->obj.libvlc, "xid-in-use");
>  }
> -- 
> 2.10.0
> 
> _______________________________________________
> 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