From 49ccd7e62309dea3304a0c7ca200794e727502a2 Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Wed, 5 Apr 2023 17:21:45 +0200 Subject: [PATCH] Another improvement of calculating the size of the extent. --- coders/tiff.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/coders/tiff.c b/coders/tiff.c index dedddda0a..044e8cc47 100644 --- a/coders/tiff.c +++ b/coders/tiff.c @@ -1814,15 +1814,14 @@ static Image *ReadTIFFImage(const ImageInfo *image_info, */ strip_size=TIFFStripSize(tiff); stride=(ssize_t) TIFFVStripSize(tiff,1); - extent=(size_t) ((samples_per_pixel+extra_samples)*strip_size); length=GetQuantumExtent(image,quantum_info,quantum_type); - if (length > stride) - extent+=length; + extent=MagickMax((size_t) strip_size,rows_per_strip* + (size_t) MagickMax(stride,length)); strip_pixels=(unsigned char *) AcquireQuantumMemory(extent, - sizeof(uint32)); + sizeof(*strip_pixels)); if (strip_pixels == (unsigned char *) NULL) ThrowTIFFException(ResourceLimitError,"MemoryAllocationFailed"); - (void) memset(strip_pixels,0,extent*sizeof(uint32)); + (void) memset(strip_pixels,0,extent*sizeof(*strip_pixels)); strip_id=0; p=strip_pixels; for (i=0; i < (ssize_t) samples_per_pixel; i++)