]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/mvha.c
avcodec/mv30: fix warning: suggest braces around initialization of subobject [-Wmissi...
[ffmpeg] / libavcodec / mvha.c
index c270063b1c2db02dcd7e434a142d29c2d1f5b191..c603ef69755fbac38e3b894057a13300e06c7d2d 100644 (file)
@@ -161,6 +161,9 @@ static int decode_frame(AVCodecContext *avctx,
     type = AV_RB32(avpkt->data);
     size = AV_RL32(avpkt->data + 4);
 
+    if (size < 1 || size >= avpkt->size)
+        return AVERROR_INVALIDDATA;
+
     if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
         return ret;
 
@@ -230,6 +233,8 @@ static int decode_frame(AVCodecContext *avctx,
 
             dst = frame->data[p] + (avctx->height - 1) * frame->linesize[p];
             for (int y = 0; y < avctx->height; y++) {
+                if (get_bits_left(gb) < width)
+                    return AVERROR_INVALIDDATA;
                 for (int x = 0; x < width; x++) {
                     int v = get_vlc2(gb, s->vlc.table, s->vlc.bits, 3);
 
@@ -253,12 +258,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;
+            }
         }
     }