about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authormogery <mo.geryy@gmail.com>2021-10-12 20:05:22 +0200
committermogery <mo.geryy@gmail.com>2021-10-12 20:05:22 +0200
commit4ca58d1f994900d2025258cadf19dd633c8a7c09 (patch)
treeb81bca65f67e5425abf4c7f5b666002b143584b5 /src
parent0c27b82ff3b8a1da27d7ed32e89c90518f9c2c0c (diff)
downloadbox64-4ca58d1f994900d2025258cadf19dd633c8a7c09.tar.gz
box64-4ca58d1f994900d2025258cadf19dd633c8a7c09.zip
Fix incorrect brick cleanup
FreeBridge used free to clean up the pointer allocated by
my_mmap, which is incorrect and lead to a crash upon code
that exited gracefully.

The free was replaced with my_munmap.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/tools/bridge.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/tools/bridge.c b/src/tools/bridge.c
index c800b8c5..4ee34824 100755
--- a/src/tools/bridge.c
+++ b/src/tools/bridge.c
@@ -6,6 +6,7 @@
 #include <pthread.h>
 #include <sys/mman.h>
 
+#include <wrappedlibs.h>
 #include "custommem.h"
 #include "bridge.h"
 #include "bridge_private.h"
@@ -59,13 +60,14 @@ void FreeBridge(bridge_t** bridge)
     if(!bridge || !*bridge)
         return;
     brick_t *b = (*bridge)->head;
+    x64emu_t* emu = thread_get_emu();
     while(b) {
         brick_t *n = b->next;
         #ifdef DYNAREC
         if(getProtection((uintptr_t)b->b)&PROT_DYNAREC)
             unprotectDB((uintptr_t)b->b, NBRICK*sizeof(onebridge_t));
         #endif
-        free(b->b);
+        my_munmap(emu, b->b, NBRICK*sizeof(onebridge_t));
         free(b);
         b = n;
     }