]> granicus.if.org Git - imagemagick/commitdiff
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=6564
authorCristy <urban-warrior@imagemagick.org>
Tue, 27 Feb 2018 01:15:33 +0000 (20:15 -0500)
committerCristy <urban-warrior@imagemagick.org>
Tue, 27 Feb 2018 01:15:33 +0000 (20:15 -0500)
coders/bmp.c

index 0535c2eb6e64a1876e90cf66841b6feb1b26a1af..579578e16a0a7edf0f8b565f0580e9e3203c8ac8 100644 (file)
@@ -961,11 +961,11 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
       bmp_info.bits_per_pixel<<=1;
     bytes_per_line=4*((image->columns*bmp_info.bits_per_pixel+31)/32);
     length=(size_t) bytes_per_line*image->rows;
+    if ((MagickSizeType) length > GetBlobSize(image))
+      ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile");
     if ((bmp_info.compression == BI_RGB) ||
         (bmp_info.compression == BI_BITFIELDS))
       {
-        if ((MagickSizeType) length > GetBlobSize(image))
-          ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile");
         pixel_info=AcquireVirtualMemory((size_t) image->rows,
           MagickMax(bytes_per_line,image->columns+256UL)*sizeof(*pixels));
         if (pixel_info == (MemoryInfo *) NULL)