From: LI Chen Date: Wed, 13 Sep 2017 03:26:08 +0000 (+0800) Subject: bugfix: the id would be changed before it is returned. This would cause a severe... X-Git-Tag: 7.0.7-3~53 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1e2d902c821e8344abc4cc76c38ffe0d26058e9a;p=imagemagick 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. --- 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); }