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

Tristan Matthews tmatth at videolan.org
Sun Jan 5 16:35:37 CET 2020


Hi,

On Sat, Jan 4, 2020 at 3:48 PM Farid Hammane <farid.hammane at gmail.com> wrote:
>
> Fix segmentation fault that occurred when
> unsupported "audiofile-format" was selected.
> ---
>  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..303dc88436 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 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 )
> +    format_list_size = (int)(sizeof(format_list) / sizeof(*format_list));
> +    for (i = 0; i < format_list_size; i++)

You can just use ARRAY_SIZE(format_list).

>      {
> -        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 == 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


More information about the vlc-devel mailing list