Commit 96eb9a30f for imagemagick.org
commit 96eb9a30f9deb549ec60983f506d69c1da5e261b
Author: Dirk Lemstra <dirk@lemstra.org>
Date: Fri Jan 16 11:07:16 2026 +0100
Added overflow checks.
diff --git a/coders/psd.c b/coders/psd.c
index e1c386603..28495c6d5 100644
--- a/coders/psd.c
+++ b/coders/psd.c
@@ -1321,9 +1321,12 @@ static MagickBooleanType ReadPSDChannelZip(Image *image,
image->filename);
packet_size=GetPSDPacketSize(image);
- row_size=image->columns*packet_size;
- count=image->rows*row_size;
-
+ if (HeapOverflowSanityCheckGetSize(image->columns,packet_size,&row_size) != MagickFalse)
+ ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
+ image->filename);
+ if (HeapOverflowSanityCheckGetSize(image->rows,row_size,&count) != MagickFalse)
+ ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
+ image->filename);
pixels=(unsigned char *) AcquireQuantumMemory(count,sizeof(*pixels));
if (pixels == (unsigned char *) NULL)
{