From: Scott Wood Date: Mon, 12 May 2008 02:11:46 +0000 (-0500) Subject: Cause excessively large malloc()s to fail rather than assert. X-Git-Url: http://git.buserror.net/cgi-bin/gitweb.cgi?p=polintos%2Fscott%2Fpriv.git;a=commitdiff_plain;h=371d6008c5366f424e4bf8889febe3cc495d0d3e 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 --- 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);