kernel/heap: Check for multiplication overflows in calloc.
Logic inspired by musl's.
This commit is contained in:
parent
eb26002b47
commit
2823fe54e1
@ -2482,6 +2482,9 @@ realloc(void *address, size_t newSize)
|
||||
void *
|
||||
calloc(size_t numElements, size_t size)
|
||||
{
|
||||
if (size != 0 && numElements > (((size_t)(-1)) / size))
|
||||
return NULL;
|
||||
|
||||
void *address = malloc(numElements * size);
|
||||
if (address != NULL)
|
||||
memset(address, 0, numElements * size);
|
||||
|
Loading…
Reference in New Issue
Block a user