[vlc-devel] [PATCH] audio_output/file: Fix a segmentation fault

Tristan Matthews tmatth at videolan.org
Mon Jan 6 06:12:26 CET 2020


On Sun, Jan 5, 2020 at 4:01 PM Farid Hammane <farid.hammane at gmail.com> wrote:
>
> Fix segmentation fault that occurred when
> unsupported "audiofile-format" was selected.
>
> format_list is not a NULL-terminated array of
> strings
>
> Signed-off-by: Farid Hammane <farid.hammane at gmail.com>
> ---
>  modules/audio_output/file.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/modules/audio_output/file.c b/modules/audio_output/file.c
> index 283b8415c9..d87dbeab93 100644
> --- a/modules/audio_output/file.c
> +++ b/modules/audio_output/file.c
> @@ -131,8 +131,8 @@ vlc_module_end ()
>  static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
>  {
>      char * psz_name, * psz_format;
> -    const char * const * ppsz_compare = format_list;
>      int i_channels, i = 0;
> +    int i_format_list_size;
>
>      if( aout_FormatNbChannels( fmt ) == 0 )
>          return VLC_EGENERIC;
> @@ -178,16 +178,16 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
>          return VLC_EGENERIC;
>      }
>
> -    while ( *ppsz_compare != NULL )
> +    i_format_list_size = (int)ARRAY_SIZE(format_list);
> +    for (i = 0; i < i_format_list_size; i++)
>      {
> -        if ( !strncmp( *ppsz_compare, psz_format, strlen(*ppsz_compare) ) )
> +        if ( !strncmp( format_list[i], psz_format, strlen(format_list[i]) ) )
>          {
>              break;
>          }
> -        ppsz_compare++; i++;
>      }
>
> -    if ( *ppsz_compare == NULL )
> +    if ( i == i_format_list_size )
>      {
>          msg_Err( p_aout, "cannot understand the format string (%s)",
>                   psz_format );
> --
> 2.20.1
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel

Applied and backported, thanks.

Best,
Tristan


More information about the vlc-devel mailing list