]> granicus.if.org Git - imagemagick/commitdiff
https://github.com/ImageMagick/ImageMagick/issues/1459
authorCristy <mikayla-grace@urban-warrior.org>
Sat, 26 Jan 2019 16:35:25 +0000 (11:35 -0500)
committerCristy <mikayla-grace@urban-warrior.org>
Sat, 26 Jan 2019 16:35:40 +0000 (11:35 -0500)
coders/bmp.c

index d49a52b9f9f6cbcf48197e7ebc12209ebf20f32c..83ff6882098649b95b9a1fda916dfcb0a7d1f8c6 100644 (file)
@@ -954,11 +954,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/256) > 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(image->rows,
           MagickMax(bytes_per_line,image->columns+256UL)*sizeof(*pixels));
         if (pixel_info == (MemoryInfo *) NULL)