From ac39aed7c5767992dd487f7ec041c430eebde2d0 Mon Sep 17 00:00:00 2001 From: Will Lillis Date: Sat, 13 Sep 2025 20:16:29 -0400 Subject: [PATCH] fix(lib/wasm): return NULL for 0-sized allocations Co-authored-by: Amaan Qureshi --- lib/src/wasm/stdlib.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/src/wasm/stdlib.c b/lib/src/wasm/stdlib.c index 1e6cf4a0..65f87e90 100644 --- a/lib/src/wasm/stdlib.c +++ b/lib/src/wasm/stdlib.c @@ -60,6 +60,8 @@ void reset_heap(void *new_heap_start) { } void *malloc(size_t size) { + if (size == 0) return NULL; + Region *prev = NULL; Region *curr = free_list; while (curr != NULL) {