]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/bmp.c
Merge commit 'f90729699db9ede2bef2b28000f1795dab1b8996'
[ffmpeg] / libavcodec / bmp.c
index 47ff9786325d81a7896ea7c3d4852e62657937b0..458fd0c768d481ea6c133b259341a95a0b3747ab 100644 (file)
@@ -70,7 +70,7 @@ static int bmp_decode_frame(AVCodecContext *avctx,
 
     hsize  = bytestream_get_le32(&buf); /* header size */
     ihsize = bytestream_get_le32(&buf); /* more header size */
-    if (ihsize + 14 > hsize) {
+    if (ihsize + 14LL > hsize) {
         av_log(avctx, AV_LOG_ERROR, "invalid header size %u\n", hsize);
         return AVERROR_INVALIDDATA;
     }
@@ -128,6 +128,7 @@ static int bmp_decode_frame(AVCodecContext *avctx,
         rgb[0] = bytestream_get_le32(&buf);
         rgb[1] = bytestream_get_le32(&buf);
         rgb[2] = bytestream_get_le32(&buf);
+        if (ihsize > 40)
         alpha = bytestream_get_le32(&buf);
     }
 
@@ -247,6 +248,8 @@ static int bmp_decode_frame(AVCodecContext *avctx,
             } else if (t) {
                 colors = t;
             }
+        } else {
+            colors = FFMIN(256, (hsize-ihsize-14) / 3);
         }
         buf = buf0 + 14 + ihsize; //palette location
         // OS/2 bitmap, 3 bytes per palette entry