avcodec/fmvc: Check nb_blocks
authorMichael Niedermayer <michael@niedermayer.cc>
Fri, 12 May 2017 23:22:27 +0000 (01:22 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Fri, 12 May 2017 23:23:23 +0000 (01:23 +0200)
Fixes: out of array read
Fixes: 1508/clusterfuzz-testcase-minimized-5011336327069696

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

index 1f8b0c5..ff5f291 100644 (file)
@@ -561,6 +561,9 @@ static av_cold int decode_init(AVCodecContext *avctx)
     }
 
     s->nb_blocks = s->xb * s->yb;
+    if (!s->nb_blocks)
+        return AVERROR_INVALIDDATA;
+
     s->blocks = av_calloc(s->nb_blocks, sizeof(*s->blocks));
     if (!s->blocks)
         return AVERROR(ENOMEM);