diff --git a/magick/cache.c b/magick/cache.c
index e7a3f5d..cbb7321 100644
--- a/magick/cache.c
+++ b/magick/cache.c
@@ -203,7 +203,8 @@
   if ((cache_resources == (SplayTreeInfo *) NULL) &&
       (instantiate_cache == MagickFalse))
     {
-      AcquireSemaphoreInfo(&cache_semaphore);
+      if (cache_semaphore == (SemaphoreInfo *) NULL)
+        AcquireSemaphoreInfo(&cache_semaphore);
       LockSemaphoreInfo(cache_semaphore);
       if ((cache_resources == (SplayTreeInfo *) NULL) &&
           (instantiate_cache == MagickFalse))