Catch some cases where asking for ridiculously large allocations could
result in a segfault. Instead just return NULL.
This commit is contained in:
parent
271aee47ec
commit
7656b3500d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=110103
@ -326,6 +326,8 @@ map_pages(size_t pages)
|
||||
|
||||
result = (caddr_t)pageround((u_long)sbrk(0));
|
||||
tail = result + (pages << malloc_pageshift);
|
||||
if (tail < result)
|
||||
return 0;
|
||||
|
||||
if (brk(tail)) {
|
||||
#ifdef EXTRA_SANITY
|
||||
@ -745,6 +747,8 @@ imalloc(size_t size)
|
||||
|
||||
if ((size + malloc_pagesize) < size) /* Check for overflow */
|
||||
result = 0;
|
||||
else if ((size + malloc_pagesize) >= (uintptr_t)page_dir)
|
||||
result = 0;
|
||||
else if (size <= malloc_maxsize)
|
||||
result = malloc_bytes(size);
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user