[vlc-devel] [PATCH] input: Fix race condition on input item titles

Rémi Denis-Courmont remi at remlab.net
Mon Aug 28 21:15:16 CEST 2017


Le maanantaina 28. elokuuta 2017, 10.26.42 EEST Hugo Beauzée-Luyssen a écrit :
> Fix #18727

As noted earlier, there are a bunch of places modifying ->title without the 
lock. I think that, if this is indeed the correct approach, then this fix is 
incomplete.

> ---
>  src/input/input.c | 30 +++++++++++++++++++++---------
>  1 file changed, 21 insertions(+), 9 deletions(-)
> 
> diff --git a/src/input/input.c b/src/input/input.c
> index ae5fe03f81..e6eb5c88ee 100644
> --- a/src/input/input.c
> +++ b/src/input/input.c
> @@ -2269,7 +2269,20 @@ static void UpdateGenericFromDemux( input_thread_t
> *p_input )
> 
>  static void UpdateTitleListfromDemux( input_thread_t *p_input )
>  {
> -    input_source_t *in = input_priv(p_input)->master;
> +    input_thread_private_t *priv = input_priv(p_input);
> +    input_source_t *in = priv->master;
> +
> +    input_title_t **pp_title = NULL;
> +    int i_title = 0;
> +    int i_offset = 0;
> +    int i_seekpoint_offset = 0;
> +
> +    /* Get the new title list */
> +    if( demux_Control( in->p_demux, DEMUX_GET_TITLE_INFO, &pp_title,
> &i_title, +                       &i_offset, &i_seekpoint_offset ) !=
> VLC_SUCCESS ) +        return;
> +
> +    vlc_mutex_lock( &priv->p_item->lock );
> 
>      /* Delete the preexisting titles */
>      if( in->i_title > 0 )
> @@ -2277,16 +2290,15 @@ static void UpdateTitleListfromDemux( input_thread_t
> *p_input ) for( int i = 0; i < in->i_title; i++ )
>              vlc_input_title_Delete( in->title[i] );
>          TAB_CLEAN( in->i_title, in->title );
> -        in->b_title_demux = false;
>      }
> 
> -    /* Get the new title list */
> -    if( demux_Control( in->p_demux, DEMUX_GET_TITLE_INFO,
> -                       &in->title, &in->i_title,
> -                       &in->i_title_offset, &in->i_seekpoint_offset ) )
> -        TAB_INIT( in->i_title, in->title );
> -    else
> -        in->b_title_demux = true;
> +    in->b_title_demux = true;
> +    in->title = pp_title;
> +    in->i_title = i_title;
> +    in->i_title_offset = i_offset;
> +    in->i_seekpoint_offset = i_seekpoint_offset;
> +
> +    vlc_mutex_unlock( &priv->p_item->lock );
> 
>      InitTitle( p_input );
>  }


-- 
雷米‧德尼-库尔蒙
https://www.remlab.net/



More information about the vlc-devel mailing list