Commit 8db4d05f3 for imagemagick.org
commit 8db4d05f31f589cccc16e38fad86bbc3193391c7
Author: Dirk Lemstra <dirk@lemstra.org>
Date: Sat Nov 14 10:50:21 2026 +0100
Preserve the same key instead of replacing it in the splay tree (GHSA-cvrx-j29f-c5q9)
diff --git a/MagickCore/splay-tree.c b/MagickCore/splay-tree.c
index 52f4b9b62..e9b6af48a 100644
--- a/MagickCore/splay-tree.c
+++ b/MagickCore/splay-tree.c
@@ -176,11 +176,10 @@ MagickExport MagickBooleanType AddValueToSplayTree(SplayTreeInfo *splay_tree,
(splay_tree->root->value != (void *) NULL))
splay_tree->root->value=splay_tree->relinquish_value(
splay_tree->root->value);
- if ((splay_tree->relinquish_key != (void *(*)(void *)) NULL) &&
- (splay_tree->root->key != (void *) NULL))
- splay_tree->root->key=splay_tree->relinquish_key(
- splay_tree->root->key);
- splay_tree->root->key=(void *) key;
+ if ((splay_tree->relinquish_key != (void *(*)(void *)) NULL) &&
+ (key != (const void *) NULL) &&
+ (key != splay_tree->root->key))
+ (void) splay_tree->relinquish_key((void *) key);
splay_tree->root->value=(void *) value;
UnlockSemaphoreInfo(splay_tree->semaphore);
return(MagickTrue);