aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/zmbv.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2018-08-27 00:49:00 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2018-09-03 00:01:32 +0200
commita73579c12d665531df9765c5b75aed5e12441d94 (patch)
treed98bae38e40370cf62ecf2736a2f1a54d954f606 /libavcodec/zmbv.c
parent42f053494ca1188fe1b9000d4bba53375ee1dc20 (diff)
downloadffmpeg-a73579c12d665531df9765c5b75aed5e12441d94.tar.gz
iavcodec/zmbv: Avoid reallocating cur/prev buffers if they are large enough
Fixes: Timeout Fixes: 9721/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ZMBV_fuzzer-5650321660444672 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/zmbv.c')
-rw-r--r--libavcodec/zmbv.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/libavcodec/zmbv.c b/libavcodec/zmbv.c
index 251a72cf31..b01ce1bcf6 100644
--- a/libavcodec/zmbv.c
+++ b/libavcodec/zmbv.c
@@ -57,6 +57,7 @@ typedef struct ZmbvContext {
AVCodecContext *avctx;
int bpp;
+ int alloc_bpp;
unsigned int decomp_size;
uint8_t* decomp_buf;
uint8_t pal[768];
@@ -494,12 +495,17 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
return AVERROR_UNKNOWN;
}
- c->cur = av_realloc_f(c->cur, avctx->width * avctx->height, (c->bpp / 8));
- c->prev = av_realloc_f(c->prev, avctx->width * avctx->height, (c->bpp / 8));
+ if (c->alloc_bpp < c->bpp) {
+ c->cur = av_realloc_f(c->cur, avctx->width * avctx->height, (c->bpp / 8));
+ c->prev = av_realloc_f(c->prev, avctx->width * avctx->height, (c->bpp / 8));
+ c->alloc_bpp = c->bpp;
+ }
c->bx = (c->width + c->bw - 1) / c->bw;
c->by = (c->height+ c->bh - 1) / c->bh;
- if (!c->cur || !c->prev)
+ if (!c->cur || !c->prev) {
+ c->alloc_bpp = 0;
return AVERROR(ENOMEM);
+ }
memset(c->cur, 0, avctx->width * avctx->height * (c->bpp / 8));
memset(c->prev, 0, avctx->width * avctx->height * (c->bpp / 8));
c->decode_intra= decode_intra;