about summary refs log tree commit diff stats
path: root/src/custommem.c
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2023-02-25 15:20:12 +0100
committerptitSeb <sebastien.chev@gmail.com>2023-02-25 15:20:12 +0100
commiteb212cd27e104ce989e483536e8be6123c594255 (patch)
tree3bba4e09eb731719cea36cbfdd75669c7d5788be /src/custommem.c
parentb604dd0bccce7cd56e3532bd083e33568f3ecf46 (diff)
downloadbox64-eb212cd27e104ce989e483536e8be6123c594255.tar.gz
box64-eb212cd27e104ce989e483536e8be6123c594255.zip
[DYNAREC] Small imrvment in managing memory protection
Diffstat (limited to 'src/custommem.c')
-rw-r--r--src/custommem.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/custommem.c b/src/custommem.c
index b9abcc3d..e261b62f 100644
--- a/src/custommem.c
+++ b/src/custommem.c
@@ -968,11 +968,12 @@ void updateProtection(uintptr_t addr, size_t size, uint32_t prot)
             memprot[i].prot = newblock;
         }
     for (uintptr_t i=idx; i<=end; ++i) {
-        uint32_t dyn=(memprot[i>>16].prot[i&0xffff]&PROT_DYN);
-        uint32_t mapped=(memprot[i>>16].prot[i&0xffff]&PROT_MMAP);
+        uint32_t old_prot = memprot[i>>16].prot[i&0xffff];
+        uint32_t dyn=(old_prot&PROT_DYN);
+        uint32_t mapped=(old_prot&PROT_MMAP);
         if(dyn && (prot&PROT_WRITE)) {   // need to remove the write protection from this block
             dyn = PROT_DYNAREC;
-            mprotect((void*)(i<<MEMPROT_SHIFT), 1<<MEMPROT_SHIFT, prot&~(PROT_WRITE|PROT_MMAP));
+            mprotect((void*)(i<<MEMPROT_SHIFT), 1<<MEMPROT_SHIFT, prot&~PROT_WRITE);
         } else if(dyn && !(prot&PROT_WRITE)) {
             dyn = PROT_DYNAREC_R;
         }