Commit d3c0a3748 for imagemagick.org
commit d3c0a37485314c5ccef72efb18f3847cd53868ba
Author: Cristy <urban-warrior@imagemagick.org>
Date: Tue Mar 24 08:29:45 2026 -0400
https://github.com/ImageMagick/ImageMagick/security/advisories/GHSA-f4qm-vj5j-9xpw
diff --git a/MagickCore/fx.c b/MagickCore/fx.c
index b85cd810d..849285607 100644
--- a/MagickCore/fx.c
+++ b/MagickCore/fx.c
@@ -2687,6 +2687,13 @@ static MagickBooleanType TranslateExpression (
ternary.addr_query = NULL_ADDRESS;
ternary.addr_colon = NULL_ADDRESS;
+ if (pfx->teDepth >= MagickMaxRecursionDepth) {
+ (void) ThrowMagickException(pfx->exception, GetMagickModule(), OptionError,
+ "Expression too deeply nested", "(depth %i exceeds limit %i)",
+ pfx->teDepth, MagickMaxRecursionDepth);
+ return MagickFalse;
+ }
+
pfx->teDepth++;
*chLimit = '\0';