]> git.sesse.net Git - ffmpeg/commitdiff
libavcodec/mvha: Check height before applying median predictor
authorMichael Niedermayer <michael@niedermayer.cc>
Sun, 9 Feb 2020 14:02:45 +0000 (15:02 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Sun, 9 Feb 2020 22:33:18 +0000 (23:33 +0100)
Fixes: out of array read
Fixes: 20495/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MVHA_fuzzer-5711179129552896
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/mvha.c

index afe5e511f21536be947ca251bd1f0c39213f37b7..1ea3bb3d76f15877b40cabc48c2526fca20f9db0 100644 (file)
@@ -256,12 +256,14 @@ static int decode_frame(AVCodecContext *avctx,
 
         dst = frame->data[p] + (avctx->height - 1) * frame->linesize[p];
         s->llviddsp.add_left_pred(dst, dst, width, 0);
-        dst -= stride;
-        lefttop = left = dst[0];
-        for (int y = 1; y < avctx->height; y++) {
-            s->llviddsp.add_median_pred(dst, dst + stride, dst, width, &left, &lefttop);
-            lefttop = left = dst[0];
+        if (avctx->height > 1) {
             dst -= stride;
+            lefttop = left = dst[0];
+            for (int y = 1; y < avctx->height; y++) {
+                s->llviddsp.add_median_pred(dst, dst + stride, dst, width, &left, &lefttop);
+                lefttop = left = dst[0];
+                dst -= stride;
+            }
         }
     }