aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-03-07 15:34:19 +0100
committerMichael Niedermayer <michaelni@gmx.at>2015-03-29 03:34:22 +0200
commit7470003e80d757de308cb2b11f44acdacc4f67fe (patch)
tree930574c2c1465f23e1473e11d7bf9085d4187139
parentee820d05127343a14f056b1ca0aec5f9f7db6a38 (diff)
downloadffmpeg-7470003e80d757de308cb2b11f44acdacc4f67fe.tar.gz
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> (cherry picked from commit 6c583e9048fe9db2ed4d7bbc75f4f1d76e82761a) Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/opusdec.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libavcodec/opusdec.c b/libavcodec/opusdec.c
index bd27ec592f..bbf76308e8 100644
--- a/libavcodec/opusdec.c
+++ b/libavcodec/opusdec.c
@@ -451,11 +451,13 @@ static int opus_decode_packet(AVCodecContext *avctx, void *data,
int coded_samples = 0;
int decoded_samples = 0;
int i, ret;
+ int delayed_samples = 0;
for (i = 0; i < c->nb_streams; i++) {
OpusStreamContext *s = &c->streams[i];
s->out[0] =
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 */
@@ -470,7 +472,7 @@ static int opus_decode_packet(AVCodecContext *avctx, void *data,
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 */
if (!frame->nb_samples) {