From 1e2d902c821e8344abc4cc76c38ffe0d26058e9a Mon Sep 17 00:00:00 2001 From: LI Chen Date: Wed, 13 Sep 2017 11:26:08 +0800 Subject: [PATCH] bugfix: the id would be changed before it is returned. This would cause a severe problem after a long time running when use multi-threads. --- MagickWand/wand.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/MagickWand/wand.c b/MagickWand/wand.c index 432c0211e..9db81255e 100644 --- a/MagickWand/wand.c +++ b/MagickWand/wand.c @@ -75,7 +75,7 @@ WandExport size_t AcquireWandId(void) { static size_t id = 0; - + size_t nID = 0; if (wand_semaphore == (SemaphoreInfo *) NULL) ActivateSemaphoreInfo(&wand_semaphore); LockSemaphoreInfo(wand_semaphore); @@ -85,8 +85,9 @@ WandExport size_t AcquireWandId(void) id++; (void) AddValueToSplayTree(wand_ids,(const void *) id,(const void *) id); instantiate_wand=MagickTrue; + nID = id; UnlockSemaphoreInfo(wand_semaphore); - return(id); + return(nID); } /* @@ -147,6 +148,6 @@ WandExport void RelinquishWandId(const size_t id) { LockSemaphoreInfo(wand_semaphore); if (wand_ids != (SplayTreeInfo *) NULL) - (void) DeleteNodeByValueFromSplayTree(wand_ids,(const void *) id); + (void) DeleteNodeFromSplayTree(wand_ids,(const void *) id); UnlockSemaphoreInfo(wand_semaphore); } -- 2.40.0