Commit 177b4089 authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/zmbv: obtain frame later

The frame is not needed that early so obtaining it later avoids
the costly operation in case other checks fail.

Fixes: Timeout (14sec -> 4sec)
Fixes: 13140/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ZMBV_fuzzer-5738330308739072

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpegReviewed-by: 's avatarTomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 61523683
...@@ -525,9 +525,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac ...@@ -525,9 +525,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
if (c->comp == 0) { // uncompressed data if (c->comp == 0) { // uncompressed data
if (c->decomp_size < len) { if (c->decomp_size < len) {
av_log(avctx, AV_LOG_ERROR, "Buffer too small\n"); av_log(avctx, AV_LOG_ERROR, "Buffer too small\n");
...@@ -553,6 +550,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac ...@@ -553,6 +550,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
av_log(avctx, AV_LOG_ERROR, "decompressed size %d is incorrect, expected %d\n", c->decomp_len, expected_size); av_log(avctx, AV_LOG_ERROR, "decompressed size %d is incorrect, expected %d\n", c->decomp_len, expected_size);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
if (c->flags & ZMBV_KEYFRAME) { if (c->flags & ZMBV_KEYFRAME) {
frame->key_frame = 1; frame->key_frame = 1;
frame->pict_type = AV_PICTURE_TYPE_I; frame->pict_type = AV_PICTURE_TYPE_I;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment