Commit af510e976 for imagemagick.org
commit af510e976301c2516aaa26ea8f88318450eeece2
Author: Cristy <urban-warrior@imagemagick.org>
Date: Tue Sep 29 07:46:36 2026 -0400
https://github.com/ImageMagick/ImageMagick/security/advisories/GHSA-83w9-w85j-h9jc
diff --git a/coders/mat.c b/coders/mat.c
index 07a293315..a833fb679 100644
--- a/coders/mat.c
+++ b/coders/mat.c
@@ -1237,7 +1237,9 @@ RestoreMSCWarning
image->colors = (size_t) GetQuantumRange(image->depth);
if (image->columns == 0 || image->rows == 0)
goto MATLAB_KO;
- if((size_t)ldblk*MATLAB_HDR.SizeY > MATLAB_HDR.ObjectSize)
+ if ((ldblk < 0) ||
+ ((size_t) ldblk > ((size_t) ~0)/MATLAB_HDR.SizeY) ||
+ (((size_t) ldblk*MATLAB_HDR.SizeY) > MATLAB_HDR.ObjectSize))
goto MATLAB_KO;
/* Image is gray when no complex flag is set and 2D Matrix */
if ((MATLAB_HDR.DimFlag == 8) &&