aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Gisquet <christophe.gisquet@gmail.com>2014-08-19 12:26:49 +0000
committerMichael Niedermayer <michaelni@gmx.at>2014-09-20 18:40:33 +0200
commitda1a8191c524a122a6656e7dcd05f4c0e2a37088 (patch)
tree80f08b3778fb23cd4a7e6e1ae47de03ef3e7dfde
parentdd9b24a48808b9cd31b93e517ff228f497b51b83 (diff)
downloadffmpeg-da1a8191c524a122a6656e7dcd05f4c0e2a37088.tar.gz
wavpackenc: proper buffer allocation
The allocation didn't account for headers, that can be easily 79 bytes. As a result, buffers allocated for a few samples (e.g. 5 in the original bug) could be undersized. Fixed ticket #2881. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at> (cherry picked from commit 2ba58bec20b0039ccc40cfba59af6d56de16e8b1) Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/wavpackenc.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libavcodec/wavpackenc.c b/libavcodec/wavpackenc.c
index bf9f918cd9..80cc088154 100644
--- a/libavcodec/wavpackenc.c
+++ b/libavcodec/wavpackenc.c
@@ -2876,10 +2876,11 @@ static int wavpack_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
return AVERROR(ENOMEM);
}
- if ((ret = ff_alloc_packet2(avctx, avpkt, s->block_samples * avctx->channels * 8)) < 0)
+ buf_size = s->block_samples * avctx->channels * 8
+ + 200 /* for headers */;
+ if ((ret = ff_alloc_packet2(avctx, avpkt, buf_size)) < 0)
return ret;
buf = avpkt->data;
- buf_size = avpkt->size;
for (s->ch_offset = 0; s->ch_offset < avctx->channels;) {
set_samplerate(s);