From 2c56ccfabeca83d0a88682f71787a87fa68cdbaf Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Mon, 19 Apr 2021 14:22:39 +0200 Subject: Fixed a small issue with Custom Mem handler and MexFreeBlock calculation --- src/custommem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') 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... } -- cgit 1.4.1