[libav-devel] [PATCH] ac3dec: fix an out-of-array read.

Justin Ruggles justin.ruggles at gmail.com
Sat Nov 23 18:02:16 CET 2013


On 11/23/2013 11:43 AM, Tim Walker wrote:
> This could fix some recent FATE failures.
> ---
>  libavcodec/ac3dec.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
> index e9ed040..fbeeccf 100644
> --- a/libavcodec/ac3dec.c
> +++ b/libavcodec/ac3dec.c
> @@ -1367,8 +1367,6 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data,
>              s->out_channels = 2;
>              s->output_mode  = AC3_CHMODE_STEREO;
>          }
> -        avctx->channels       = s->out_channels;
> -        avctx->channel_layout = avpriv_ac3_channel_layout_tab[s->output_mode];
>  
>          /* set downmixing coefficients if needed */
>          if (s->channels != s->out_channels && !((s->output_mode & AC3_OUTPUT_LFEON) &&
> @@ -1380,6 +1378,9 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data,
>          return AVERROR_INVALIDDATA;
>      }
>      avctx->channels = s->out_channels;
> +    avctx->channel_layout = avpriv_ac3_channel_layout_tab[s->output_mode & 0x7];
> +    if (s->output_mode & AC3_OUTPUT_LFEON)
> +        avctx->channel_layout |= AV_CH_LOW_FREQUENCY;
>  
>      /* set audio service type based on bitstream mode for AC-3 */
>      avctx->audio_service_type = s->bitstream_mode;

Using ~AC3_OUTPUT_LFEON instead of 0x7, as is done lower in the code,
would make it more understandable.

Otherwise looks good.

Thanks,
Justin



More information about the libav-devel mailing list