]> git.sesse.net Git - ffmpeg/commitdiff
msrledec: check bounds before constructing a possibly invalid pointer,
authorAnton Khirnov <anton@khirnov.net>
Tue, 29 Jan 2013 11:24:09 +0000 (12:24 +0100)
committerAnton Khirnov <anton@khirnov.net>
Wed, 6 Feb 2013 09:21:52 +0000 (10:21 +0100)
CC:libav-stable@libav.org

libavcodec/msrledec.c

index fad94151c97f734023778bc9261f2b665bbbe641..af2a2478b1a6ef30754b9584f659e762460ebef1 100644 (file)
@@ -144,8 +144,7 @@ static int msrle_decode_8_16_24_32(AVCodecContext *avctx, AVPicture *pic,
         if(p1 == 0) { //Escape code
             p2 = bytestream2_get_byte(gb);
             if(p2 == 0) { //End-of-line
-                output = pic->data[0] + (--line) * pic->linesize[0];
-                if (line < 0) {
+                if (--line < 0) {
                     if (bytestream2_get_be16(gb) == 1) { // end-of-picture
                         return 0;
                     } else {
@@ -155,6 +154,7 @@ static int msrle_decode_8_16_24_32(AVCodecContext *avctx, AVPicture *pic,
                         return AVERROR_INVALIDDATA;
                     }
                 }
+                output = pic->data[0] + line * pic->linesize[0];
                 pos = 0;
                 continue;
             } else if(p2 == 1) { //End-of-picture