avcodec/pictordec: Only recalculate d when y changes in picmemset()
authorMichael Niedermayer <michael@niedermayer.cc>
Fri, 12 Apr 2019 23:19:03 +0000 (01:19 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Fri, 19 Apr 2019 19:06:40 +0000 (21:06 +0200)
Fixes: Timeout (21->18sec)
Fixes: 14124/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PICTOR_fuzzer-5633887734071296

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/pictordec.c

index af99c48..2e6fcdc 100644 (file)
@@ -68,10 +68,10 @@ static void picmemset(PicContext *s, AVFrame *frame, unsigned value, int run,
     int planel = *plane;
     value   <<= shift;
 
+    d = frame->data[0] + yl * frame->linesize[0];
     while (run > 0) {
         int j;
         for (j = 8-bits_per_plane; j >= 0; j -= bits_per_plane) {
-            d = frame->data[0] + yl * frame->linesize[0];
             d[xl] |= (value >> j) & mask;
             xl += 1;
             if (xl == s->width) {
@@ -85,6 +85,7 @@ static void picmemset(PicContext *s, AVFrame *frame, unsigned value, int run,
                    value <<= bits_per_plane;
                    mask  <<= bits_per_plane;
                 }
+                d = frame->data[0] + yl * frame->linesize[0];
             }
         }
         run--;