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

Farid Hammane git at videolan.org
Mon Jan 6 06:12:12 CET 2020


vlc/vlc-3.0 | branch: master | Farid Hammane <farid.hammane at gmail.com> | Sun Jan  5 22:01:35 2020 +0100| [ecc976e468a571f569cb9f5cde3d5ea3dcf1d5a8] | committer: Tristan Matthews

audio_output/file: Fix a segmentation fault

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>
Signed-off-by: Tristan Matthews <tmatth at videolan.org>
(cherry picked from commit 15a9c9b26860638e258a83f1682f2be6690ad147)
Signed-off-by: Tristan Matthews <tmatth at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=ecc976e468a571f569cb9f5cde3d5ea3dcf1d5a8
---

 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 6c6c59cfb4..fd811e9c23 100644
--- a/modules/audio_output/file.c
+++ b/modules/audio_output/file.c
@@ -132,8 +132,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 );



More information about the vlc-commits mailing list