diff mbox

[FFmpeg-devel,1/2] avcodec/zmbv: obtain frame later

Message ID 20190221193429.19600-1-michael@niedermayer.cc
State Accepted
Commit 177b40890c6de8c6896e0a1d4a631ea1ca89c044
Headers show

Commit Message

Michael Niedermayer Feb. 21, 2019, 7:34 p.m. UTC
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/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/zmbv.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Tomas Härdin Feb. 22, 2019, 12:45 p.m. UTC | #1
tor 2019-02-21 klockan 20:34 +0100 skrev Michael Niedermayer:
> 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/ffmpeg
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/zmbv.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Looks OK, passes FATE

/Tomas
Michael Niedermayer Feb. 22, 2019, 9:40 p.m. UTC | #2
On Fri, Feb 22, 2019 at 01:45:25PM +0100, Tomas Härdin wrote:
> tor 2019-02-21 klockan 20:34 +0100 skrev Michael Niedermayer:
> > 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/ffmpeg
> > > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavcodec/zmbv.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> Looks OK, passes FATE

will apply

thanks

[...]
diff mbox

Patch

diff --git a/libavcodec/zmbv.c b/libavcodec/zmbv.c
index 79e0892070..e07009d0fb 100644
--- a/libavcodec/zmbv.c
+++ b/libavcodec/zmbv.c
@@ -525,9 +525,6 @@  static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
         return AVERROR_INVALIDDATA;
     }
 
-    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
-        return ret;
-
     if (c->comp == 0) { // uncompressed data
         if (c->decomp_size < len) {
             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
         av_log(avctx, AV_LOG_ERROR, "decompressed size %d is incorrect, expected %d\n", c->decomp_len, expected_size);
         return AVERROR_INVALIDDATA;
     }
+    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
+        return ret;
+
     if (c->flags & ZMBV_KEYFRAME) {
         frame->key_frame = 1;
         frame->pict_type = AV_PICTURE_TYPE_I;