about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/custommem.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/custommem.c b/src/custommem.c
index 8424ea1b..a2c3e992 100644
--- a/src/custommem.c
+++ b/src/custommem.c
@@ -432,10 +432,11 @@ uintptr_t AllocDynarecMap(dynablock_t* db, size_t size)
     if(!size)
         return 0;
     if(size>MMAPSIZE-2*sizeof(blockmark_t)) {
-        #ifndef USE_MMAP
         pthread_mutex_lock(&mutex_mmap);
+        #ifndef USE_MMAP
         void *p = NULL;
         if(posix_memalign(&p, box64_pagesize, size)) {
+            pthread_mutex_unlock(&mutex_mmap);
             dynarec_log(LOG_INFO, "Cannot create dynamic map of %zu bytes\n", size);
             return 0;
         }
@@ -443,6 +444,7 @@ uintptr_t AllocDynarecMap(dynablock_t* db, size_t size)
         #else
         void* p = mmap(NULL, size, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
         if(p==(void*)-1) {
+            pthread_mutex_unlock(&mutex_mmap);
             dynarec_log(LOG_INFO, "Cannot create dynamic map of %zu bytes\n", size);
             return 0;
         }