[vlc-commits] faad: Fix a crash when channel info are invalids.

Hugo Beauzée-Luyssen git at videolan.org
Sun May 6 03:05:05 CEST 2012


vlc/vlc-2.0 | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Fri May  4 15:15:40 2012 +0200| [0c3e5b21f09947d3b49bc2805225b1f2a437160d] | committer: Jean-Baptiste Kempf

faad: Fix a crash when channel info are invalids.

Fix #5433
(cherry picked from commit 5db50265be1ba6537daa3a08ac368668bf1455b0)

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?a=commit;h=0c3e5b21f09947d3b49bc2805225b1f2a437160d
---

 modules/codec/faad.c |   23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/modules/codec/faad.c b/modules/codec/faad.c
index 38e50a3..94c7d11 100644
--- a/modules/codec/faad.c
+++ b/modules/codec/faad.c
@@ -459,10 +459,19 @@ static aout_buffer_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
             else
                 p_dec->fmt_out.audio.i_physical_channels |= pi_channels_out[j];
         }
-        p_dec->fmt_out.audio.i_original_channels =
-            p_dec->fmt_out.audio.i_physical_channels;
-
-        p_out = decoder_NewAudioBuffer(p_dec, frame.samples/frame.channels);
+        if ( nbChannels != frame.channels )
+        {
+            p_dec->fmt_out.audio.i_physical_channels
+                = p_dec->fmt_out.audio.i_original_channels
+                = pi_channels_guessed[nbChannels];
+        }
+        else
+        {
+            p_dec->fmt_out.audio.i_original_channels =
+                p_dec->fmt_out.audio.i_physical_channels;
+        }
+        p_dec->fmt_out.audio.i_channels = nbChannels;
+        p_out = decoder_NewAudioBuffer( p_dec, frame.samples / nbChannels );
         if( p_out == NULL )
         {
             p_sys->i_buffer = 0;
@@ -472,11 +481,11 @@ static aout_buffer_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
 
         p_out->i_pts = date_Get( &p_sys->date );
         p_out->i_length = date_Increment( &p_sys->date,
-                                          frame.samples / frame.channels )
+                                          frame.samples / nbChannels )
                           - p_out->i_pts;
 
         DoReordering( (uint32_t *)p_out->p_buffer, samples,
-                      frame.samples / frame.channels, frame.channels,
+                      frame.samples / nbChannels, nbChannels,
                       p_sys->pi_channel_positions );
 
         p_sys->i_buffer -= frame.bytesconsumed;
@@ -513,7 +522,7 @@ static void Close( vlc_object_t *p_this )
 static void DoReordering( uint32_t *p_out, uint32_t *p_in, int i_samples,
                           int i_nb_channels, uint32_t *pi_chan_positions )
 {
-    int pi_chan_table[MAX_CHANNEL_POSITIONS];
+    int pi_chan_table[MAX_CHANNEL_POSITIONS] = {0};
     int i, j, k;
 
     /* Find the channels mapping */



More information about the vlc-commits mailing list