Commit be32410a4 for imagemagick.org
commit be32410a4488483bff53da08d733d96caaedc1c8
Author: Cristy <urban-warrior@imagemagick.org>
Date: Fri Nov 27 22:09:12 2026 -0500
AcquireWandId() on NULL skips the insert
diff --git a/MagickWand/wand.c b/MagickWand/wand.c
index f118f7c68..17a8d595b 100644
--- a/MagickWand/wand.c
+++ b/MagickWand/wand.c
@@ -68,7 +68,7 @@ static SemaphoreInfo
%
% The format of the AcquireWandId() method is:
%
-% size_t AcquireWandId()
+% size_t AcquireWandId(void)
%
*/
WandExport size_t AcquireWandId(void)
@@ -85,9 +85,10 @@ WandExport size_t AcquireWandId(void)
if (wand_ids == (SplayTreeInfo *) NULL)
wand_ids=NewSplayTree((int (*)(const void *,const void *)) NULL,
(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
- wand_id=id++;
- (void) AddValueToSplayTree(wand_ids,(const void *) wand_id,(const void *)
- wand_id);
+ wand_id=(MagickAddressType) id++;
+ if (wand_ids != (SplayTreeInfo *) NULL)
+ (void) AddValueToSplayTree(wand_ids,(const void *) wand_id,(const void *)
+ wand_id);
UnlockSemaphoreInfo(wand_semaphore);
return((size_t) wand_id);
}
@@ -109,8 +110,6 @@ WandExport size_t AcquireWandId(void)
%
% void DestroyWandIds(void)
%
-% A description of each parameter follows:
-%
*/
WandExport void DestroyWandIds(void)
{
@@ -138,7 +137,7 @@ WandExport void DestroyWandIds(void)
%
% The format of the RelinquishWandId() method is:
%
-% void RelinquishWandId(const size_t *id)
+% void RelinquishWandId(const size_t id)
%
% A description of each parameter follows:
%
@@ -150,6 +149,8 @@ WandExport void RelinquishWandId(const size_t id)
MagickAddressType
wand_id = (MagickAddressType) id;
+ if (wand_semaphore == (SemaphoreInfo *) NULL)
+ ActivateSemaphoreInfo(&wand_semaphore);
LockSemaphoreInfo(wand_semaphore);
if (wand_ids != (SplayTreeInfo *) NULL)
(void) DeleteNodeFromSplayTree(wand_ids,(const void *) wand_id);