1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avcodec/opusdec: Fix delayed sample value

Fixes out of array access
Fixes: ffmpeg_opus_crash1.ogg

This solution is likely not optimal in terms of error concealment but
its simple and fixes the out of array access.

Found-by: Thomas Lindroth <thomas.lindroth@gmail.com>
Tested-by: Thomas Lindroth <thomas.lindroth@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2015-03-07 15:34:19 +01:00
parent 1ae092587f
commit 6c583e9048

View File

@ -449,11 +449,13 @@ static int opus_decode_packet(AVCodecContext *avctx, void *data,
int coded_samples = 0; int coded_samples = 0;
int decoded_samples = 0; int decoded_samples = 0;
int i, ret; int i, ret;
int delayed_samples = 0;
for (i = 0; i < c->nb_streams; i++) { for (i = 0; i < c->nb_streams; i++) {
OpusStreamContext *s = &c->streams[i]; OpusStreamContext *s = &c->streams[i];
s->out[0] = s->out[0] =
s->out[1] = NULL; s->out[1] = NULL;
delayed_samples = FFMAX(delayed_samples, s->delayed_samples);
} }
/* decode the header of the first sub-packet to find out the sample count */ /* decode the header of the first sub-packet to find out the sample count */
@ -468,7 +470,7 @@ static int opus_decode_packet(AVCodecContext *avctx, void *data,
c->streams[0].silk_samplerate = get_silk_samplerate(pkt->config); c->streams[0].silk_samplerate = get_silk_samplerate(pkt->config);
} }
frame->nb_samples = coded_samples + c->streams[0].delayed_samples; frame->nb_samples = coded_samples + delayed_samples;
/* no input or buffered data => nothing to do */ /* no input or buffered data => nothing to do */
if (!frame->nb_samples) { if (!frame->nb_samples) {