aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/shorten.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2011-09-16 18:01:28 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2011-10-20 13:09:26 -0400
commit882dafe9b666a7333d1b256fafe63e35dc582e3f (patch)
tree696218ab0e91920744b83d771b5ac6f2e768605d /libavcodec/shorten.c
parentbd7f7d6c7813ccf4ef1daaa7b01463f31fe7a7d4 (diff)
downloadffmpeg-882dafe9b666a7333d1b256fafe63e35dc582e3f.tar.gz
shorten: check output buffer size before decoding
Diffstat (limited to 'libavcodec/shorten.c')
-rw-r--r--libavcodec/shorten.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c
index ec50fc1c6e..803175827d 100644
--- a/libavcodec/shorten.c
+++ b/libavcodec/shorten.c
@@ -550,9 +550,15 @@ static int shorten_decode_frame(AVCodecContext *avctx,
/* if this is the last channel in the block, output the samples */
s->cur_chan++;
if (s->cur_chan == s->channels) {
+ int out_size = s->blocksize * s->channels *
+ av_get_bytes_per_sample(avctx->sample_fmt);
+ if (*data_size < out_size) {
+ av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
+ return AVERROR(EINVAL);
+ }
samples = interleave_buffer(samples, s->channels, s->blocksize, s->decoded);
s->cur_chan = 0;
- *data_size = (int8_t *)samples - (int8_t *)data;
+ *data_size = out_size;
} else {
*data_size = 0;
}