[FFmpeg-devel,1/2] avcodec/pafvideo: Clear frame buffer later

Submitted by Michael Niedermayer on May 17, 2019, 10:27 p.m.

Details

Message ID 20190517222733.20113-1-michael@niedermayer.cc
State Accepted
Commit 89836ad5a7a80a353ae3710a00d9708fc6437464
Headers show

Commit Message

Michael Niedermayer May 17, 2019, 10:27 p.m.
This way the clearing can be skipped in case of some errors.

Fixes: Timeout (11sec -> 344ms)
Fixes: 14670/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PAF_VIDEO_fuzzer-5769534503387136

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

Comments

Michael Niedermayer June 4, 2019, 8:55 a.m.
On Sat, May 18, 2019 at 12:27:32AM +0200, Michael Niedermayer wrote:
> This way the clearing can be skipped in case of some errors.
> 
> Fixes: Timeout (11sec -> 344ms)
> Fixes: 14670/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PAF_VIDEO_fuzzer-5769534503387136
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/pafvideo.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)

will apply patchset

[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/pafvideo.c b/libavcodec/pafvideo.c
index 7bfd6815df..323c662c59 100644
--- a/libavcodec/pafvideo.c
+++ b/libavcodec/pafvideo.c
@@ -293,9 +293,6 @@  static int paf_video_decode(AVCodecContext *avctx, void *data,
         return ret;
 
     if (code & 0x20) {  // frame is keyframe
-        for (i = 0; i < 4; i++)
-            memset(c->frame[i], 0, c->frame_size);
-
         memset(c->pic->data[1], 0, AVPALETTE_SIZE);
         c->current_frame  = 0;
         c->pic->key_frame = 1;
@@ -332,6 +329,10 @@  static int paf_video_decode(AVCodecContext *avctx, void *data,
         c->pic->palette_has_changed = 1;
     }
 
+    if (code & 0x20)
+        for (i = 0; i < 4; i++)
+            memset(c->frame[i], 0, c->frame_size);
+
     switch (code & 0x0F) {
     case 0:
         /* Block-based motion compensation using 4x4 blocks with either