about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2021-04-19 14:22:39 +0200
committerptitSeb <sebastien.chev@gmail.com>2021-04-19 14:22:39 +0200
commit2c56ccfabeca83d0a88682f71787a87fa68cdbaf (patch)
tree854416dabab44ce6864802b4034441d6f81a37b2
parentd1497e98dbb025ab610805377eb6b1d10c6435a9 (diff)
downloadbox64-2c56ccfabeca83d0a88682f71787a87fa68cdbaf.tar.gz
box64-2c56ccfabeca83d0a88682f71787a87fa68cdbaf.zip
Fixed a small issue with Custom Mem handler and MexFreeBlock calculation
-rw-r--r--src/custommem.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/custommem.c b/src/custommem.c
index 7f176fa3..80adb476 100644
--- a/src/custommem.c
+++ b/src/custommem.c
@@ -96,7 +96,9 @@ static size_t getMaxFreeBlock(void* block, size_t block_size)
     int maxsize = 0;
     while(m->prev.x32) {    // while there is a subblock
         if(!m->prev.fill && m->prev.size>maxsize) {
-            maxsize = m->prev.size-sizeof(blockmark_t);
+            maxsize = m->prev.size;
+            if(maxsize>sizeof(blockmark_t))
+                maxsize -= sizeof(blockmark_t);
             if((uintptr_t)block+maxsize>(uintptr_t)m)
                 return maxsize; // no block large enough left...
         }