Skip to content

Commit

Permalink
Fixed check for the number of pixels that will be allocated.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemstra committed Oct 5, 2015
1 parent 70aa59b commit 2ad6d33
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions coders/rle.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ static Image *ReadRLEImage(const ImageInfo *image_info,ExceptionInfo *exception)
map_length,
number_colormaps,
number_planes,
number_planes_filled,
one,
offset,
pixel_info_length;
Expand Down Expand Up @@ -308,9 +309,12 @@ static Image *ReadRLEImage(const ImageInfo *image_info,ExceptionInfo *exception)
if (image->alpha_trait != UndefinedPixelTrait)
number_planes++;
number_pixels=(MagickSizeType) image->columns*image->rows;
if ((number_pixels*number_planes) != (size_t) (number_pixels*number_planes))
number_planes_filled=(number_planes % 2 == 0) ? number_planes :
number_planes+1;
if ((number_pixels*number_planes_filled) != (size_t) (number_pixels*
number_planes_filled))
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
pixel_info_length=image->columns*image->rows*MagickMax(number_planes,4);
pixel_info_length=image->columns*image->rows*number_planes_filled;
pixel_info=AcquireVirtualMemory(pixel_info_length,sizeof(*pixels));
if (pixel_info == (MemoryInfo *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
Expand Down

0 comments on commit 2ad6d33

Please sign in to comment.