From 371d6008c5366f424e4bf8889febe3cc495d0d3e Mon Sep 17 00:00:00 2001 From: Scott Wood Date: Sun, 11 May 2008 21:11:46 -0500 Subject: [PATCH] Cause excessively large malloc()s to fail rather than assert. GCC's exception frame searching will malloc() larger than a page; returning NULL forces it to fall back on slower, in-place searching. Signed-off-by: Scott Wood --- kernel/lib/libc.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/lib/libc.cc b/kernel/lib/libc.cc index 6518988..8d9685a 100644 --- a/kernel/lib/libc.cc +++ b/kernel/lib/libc.cc @@ -34,7 +34,8 @@ void bzero(void *b, size_t len) void *malloc(size_t len) { - assert(len <= Arch::page_size - sizeof(size_t)); + if (len > Arch::page_size - sizeof(size_t)) + return NULL; len = (len + sizeof(size_t) + Arch::page_size - 1) / Arch::page_size; Mem::Page *page = Mem::PageAlloc::alloc(len); -- 2.39.2