[FFmpeg-devel] [PATCH 2/6] avcodec/escape130: move get_buffer down

Michael Niedermayer michael at niedermayer.cc
Sun Dec 8 05:56:59 EET 2024


This way the (slow) allocation of an image is done after various additional checks

Fixes: Timeout
Fixes: 379418967/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ESCAPE130_fuzzer-6507383574036480

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavcodec/escape130.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/escape130.c b/libavcodec/escape130.c
index 3b0460fd79a..4482a0e0704 100644
--- a/libavcodec/escape130.c
+++ b/libavcodec/escape130.c
@@ -212,9 +212,6 @@ static int escape130_decode_frame(AVCodecContext *avctx, AVFrame *pic,
         return AVERROR_INVALIDDATA;
     }
 
-    if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
-        return ret;
-
     if ((ret = init_get_bits8(&gb, avpkt->data, avpkt->size)) < 0)
         return ret;
     skip_bits_long(&gb, 16 * 8);
@@ -310,6 +307,9 @@ static int escape130_decode_frame(AVCodecContext *avctx, AVFrame *pic,
         skip--;
     }
 
+    if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
+        return ret;
+
     new_y  = s->new_y;
     new_cb = s->new_u;
     new_cr = s->new_v;
-- 
2.47.0



More information about the ffmpeg-devel mailing list