[vlc-devel] [PATCH] decoder: thumbnailer: Fix unprotected access to b_first

Steve Lhomme robux4 at ycbcr.xyz
Wed Oct 2 07:53:24 CEST 2019


Maybe an atomic bool would be more appropriate  ?

On 2019-10-01 18:33, Hugo Beauzée-Luyssen wrote:
> ---
>   src/input/decoder.c | 17 +++++++++++++----
>   1 file changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/src/input/decoder.c b/src/input/decoder.c
> index 57c9de6a1e..bb1beca38d 100644
> --- a/src/input/decoder.c
> +++ b/src/input/decoder.c
> @@ -1101,19 +1101,28 @@ static picture_t *thumbnailer_buffer_new( decoder_t *p_dec )
>       struct decoder_owner *p_owner = dec_get_owner( p_dec );
>       /* Avoid decoding more than one frame when a thumbnail was
>        * already generated */
> +    vlc_mutex_lock( &p_owner->lock );
>       if( !p_owner->b_first )
> +    {
> +        vlc_mutex_unlock( &p_owner->lock );
>           return NULL;
> +    }
> +    vlc_mutex_unlock( &p_owner->lock );
>       return picture_NewFromFormat( &p_dec->fmt_out.video );
>   }
>   
>   static void ModuleThread_QueueThumbnail( decoder_t *p_dec, picture_t *p_pic )
>   {
>       struct decoder_owner *p_owner = dec_get_owner( p_dec );
> -    if( p_owner->b_first )
> -    {
> +    bool b_first;
> +
> +    vlc_mutex_lock( &p_owner->lock );
> +    b_first = p_owner->b_first;
> +    p_owner->b_first = false;
> +    vlc_mutex_unlock( &p_owner->lock );
> +
> +    if( b_first )
>           decoder_Notify(p_owner, on_thumbnail_ready, p_pic);
> -        p_owner->b_first = false;
> -    }
>       picture_Release( p_pic );
>   
>   }
> -- 
> 2.20.1
> 
> _______________________________________________
> 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