aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2019-09-25 15:54:45 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2019-12-31 19:51:56 +0100
commit922837561b928e31ac1fde5835a69680c385f23c (patch)
treeeb0d679cf84f5ae81a5464901ec876438aa36565 /libavcodec
parentf3c4718f1b94c4809349b93713f5ede590538b60 (diff)
downloadffmpeg-922837561b928e31ac1fde5835a69680c385f23c.tar.gz
avcodec/wmaprodec: get frame during frame decode
Fixes: memleak Fixes: 17615/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_XMA2_fuzzer-5681306024804352 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 0f89a2293ea5f642a67700225d76948ed154418e) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/wmaprodec.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c
index 41ca792548..e001dd6e4e 100644
--- a/libavcodec/wmaprodec.c
+++ b/libavcodec/wmaprodec.c
@@ -1793,6 +1793,12 @@ static int xma_decode_packet(AVCodecContext *avctx, void *data,
AVFrame *frame = data;
int i, ret, offset = INT_MAX;
+ if (!s->frames[s->current_stream]->data[0]) {
+ s->frames[s->current_stream]->nb_samples = 512;
+ if ((ret = ff_get_buffer(avctx, s->frames[s->current_stream], 0)) < 0) {
+ return ret;
+ }
+ }
/* decode current stream packet */
ret = decode_packet(avctx, &s->xma[s->current_stream], s->frames[s->current_stream],
&got_stream_frame_ptr, avpkt);
@@ -1920,10 +1926,6 @@ static av_cold int xma_decode_init(AVCodecContext *avctx)
s->frames[i] = av_frame_alloc();
if (!s->frames[i])
return AVERROR(ENOMEM);
- s->frames[i]->nb_samples = 512;
- if ((ret = ff_get_buffer(avctx, s->frames[i], 0)) < 0) {
- return AVERROR(ENOMEM);
- }
s->start_channel[i] = start_channels;
start_channels += s->xma[i].nb_channels;