about summary refs log tree commit diff stats
path: root/src/wrapped
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2023-05-05 13:49:06 +0200
committerptitSeb <sebastien.chev@gmail.com>2023-05-05 13:49:06 +0200
commit49dfbee2119ce52600f7acbf61af690d6c9ef16c (patch)
tree5cc28c28631fe8ac7736eea8a95223a0814ebcae /src/wrapped
parent3fc3875e82402f788c85db9de16851570d69346f (diff)
downloadbox64-49dfbee2119ce52600f7acbf61af690d6c9ef16c.tar.gz
box64-49dfbee2119ce52600f7acbf61af690d6c9ef16c.zip
Improved handling of x86_64 47bits memory (should help #763)
Diffstat (limited to 'src/wrapped')
-rwxr-xr-xsrc/wrapped/wrappedlibc.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c
index cc68c216..3f4e7a09 100755
--- a/src/wrapped/wrappedlibc.c
+++ b/src/wrapped/wrappedlibc.c
@@ -2590,7 +2590,7 @@ EXPORT void* my_mremap(x64emu_t* emu, void* old_addr, size_t old_size, size_t ne
             freeProtection((uintptr_t)ret+new_size, old_size-new_size);
             #ifdef DYNAREC
             if(box64_dynarec)
-                cleanDBFromAddressRange((uintptr_t)ret+new_size, new_size-old_size, 1);
+                cleanDBFromAddressRange((uintptr_t)ret+new_size, old_size-new_size, 1);
             #endif
         } else if(!old_size) {
             setProtection((uintptr_t)ret, new_size, prot);
@@ -2644,14 +2644,14 @@ EXPORT int my_mprotect(x64emu_t* emu, void *addr, unsigned long len, int prot)
         prot|=PROT_READ;    // PROT_READ is implicit with PROT_WRITE on x86_64
     int ret = mprotect(addr, len, prot);
     #ifdef DYNAREC
-    if(box64_dynarec && !ret) {
+    if(box64_dynarec && !ret && len) {
         if(prot& PROT_EXEC)
             addDBFromAddressRange((uintptr_t)addr, len);
         else
             cleanDBFromAddressRange((uintptr_t)addr, len, 0);
     }
     #endif
-    if(!ret)
+    if(!ret && len)
         updateProtection((uintptr_t)addr, len, prot);
     return ret;
 }