From 5b3eb577fcabe32cf6f2b60c650a3d06bce718e2 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Mon, 19 Apr 2021 14:44:09 +0200 Subject: [PATCH] Fixed a small issue with Custom Mem handler and MexFreeBlock calculation --- src/custommem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/custommem.c b/src/custommem.c index 23f5ba3d..6839e749 100644 --- a/src/custommem.c +++ b/src/custommem.c @@ -92,7 +92,9 @@ static int 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); // remove the marker + maxsize = m->prev.size; + if(maxsize>sizeof(blockmark_t)) // remove the marker + maxsize -= sizeof(blockmark_t); if((uintptr_t)block+maxsize>(uintptr_t)m) return maxsize; // no block large enough left... }