Commit ae679e2fd for imagemagick.org
commit ae679e2fd19ec656bfab9f822ae4cf06bf91604d
Author: Cristy <urban-warrior@imagemagick.org>
Date: Tue Mar 24 11:33:21 2026 -0400
https://github.com/ImageMagick/ImageMagick/security/advisories/GHSA-cr67-pvmx-2pp2
diff --git a/MagickCore/xml-tree.c b/MagickCore/xml-tree.c
index 51de8ecbc..4850f851b 100644
--- a/MagickCore/xml-tree.c
+++ b/MagickCore/xml-tree.c
@@ -1919,8 +1919,8 @@ MagickExport XMLTreeInfo *NewXMLTree(const char *xml,ExceptionInfo *exception)
"ParseError","UTF16 to UTF8 failed");
return((XMLTreeInfo *) NULL);
}
- terminal=utf8[length-1];
- utf8[length-1]='\0';
+ terminal=utf8[MagickMax(length-1,0)];
+ utf8[MagickMax(length-1,0)]='\0';
p=utf8;
while ((*p != '\0') && (*p != '<'))
p++;