From 72e46f24bdd522bbb9755def295d891111a1fc16 Mon Sep 17 00:00:00 2001 From: dzaima Date: Wed, 9 Oct 2024 03:26:55 +0300 Subject: [PATCH] fix silent truncation of requested memory amount in 32-bit builds --- src/opt/mm_buddyTemplate.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/opt/mm_buddyTemplate.c b/src/opt/mm_buddyTemplate.c index beee4e36..9a73902b 100644 --- a/src/opt/mm_buddyTemplate.c +++ b/src/opt/mm_buddyTemplate.c @@ -68,6 +68,7 @@ static NOINLINE void* BN(allocateMore)(ux bucket, u8 type, ux from, ux to) { u8* mem = calloc(reqsz, 1); if (mem_log_enabled) fprintf(stderr, "\n"); #else + if (reqsz != (size_t) reqsz) thrOOM(); // otherwise it gets silently truncated in 32-bit builds u8* mem = MMAP(reqsz); if (mem_log_enabled) fprintf(stderr, ": %s\n", mem==MAP_FAILED? "failed" : "success"); if (mem==MAP_FAILED) thrOOM();