Bug #3114 » nmalloc.c.diff
lib/libc/stdlib/nmalloc.c | ||
---|---|---|
return(0);
|
||
}
|
||
#define MUL_NO_OVERFLOW (1UL << (sizeof(size_t) * 4))
|
||
/*
|
||
* malloc() - call internal slab allocator
|
||
*/
|
||
... | ... | |
{
|
||
void *ptr;
|
||
if ((size >= MUL_NO_OVERFLOW ) || (SIZE_MAX < size)) {
|
||
errno = ENOMEM;
|
||
return(NULL);
|
||
}
|
||
ptr = _slaballoc(size, 0);
|
||
if (ptr == NULL)
|
||
errno = ENOMEM;
|
||
... | ... | |
return(ptr);
|
||
}
|
||
#define MUL_NO_OVERFLOW (1UL << (sizeof(size_t) * 4))
|
||
/*
|
||
* calloc() - call internal slab allocator
|
||
*/
|
||
... | ... | |
bigalloc_t big;
|
||
bigalloc_t *bigp;
|
||
if ((size >= MUL_NO_OVERFLOW ) || (SIZE_MAX < size) ) {
|
||
return(NULL);
|
||
}
|
||
/*
|
||
* Page-align and cache-color in case of virtually indexed
|
||
* physically tagged L1 caches (aka SandyBridge). No sweat
|
||
... | ... | |
*
|
||
* (don't count as excess).
|
||
*/
|
||
size = (size + PAGE_MASK) & ~(size_t)PAGE_MASK;
|
||
size = (size + PAGE_MASK) & ~(size_t)PAGE_MASK; /* Note: Changing size, without checking overflow.
|
||
also might be better to use a different variable instead of the original request size */
|
||
/*
|
||
* If we have overflown above when rounding to the page
|