Commit 0c3e5b21 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen Committed by Jean-Baptiste Kempf

faad: Fix a crash when channel info are invalids.

Fix #5433
(cherry picked from commit 5db50265be1ba6537daa3a08ac368668bf1455b0)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent a6dd86b1
......@@ -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];
}
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_out = decoder_NewAudioBuffer(p_dec, frame.samples/frame.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 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment