mirror of https://git.kore.io/kore.git
Revert incorrect parameter validation
This commit is contained in:
parent
0c51d9da53
commit
ac45e8cd62
13
src/mem.c
13
src/mem.c
|
@ -89,19 +89,12 @@ kore_realloc(void *ptr, size_t len)
|
||||||
void *
|
void *
|
||||||
kore_calloc(size_t memb, size_t len)
|
kore_calloc(size_t memb, size_t len)
|
||||||
{
|
{
|
||||||
void *result;
|
if (memb == 0 || len == 0)
|
||||||
const size_t nbytes = memb * len;
|
|
||||||
|
|
||||||
if (nbytes == 0)
|
|
||||||
fatal("kore_calloc(): zero size");
|
fatal("kore_calloc(): zero size");
|
||||||
if (nbytes > SIZE_MAX)
|
if (SIZE_MAX / memb < len)
|
||||||
fatal("kore_calloc: memb * len > SIZE_MAX");
|
fatal("kore_calloc: memb * len > SIZE_MAX");
|
||||||
|
|
||||||
result = kore_malloc(nbytes);
|
|
||||||
if (result == NULL)
|
|
||||||
fatal("kore_calloc: alloc failed for %zd bytes", nbytes);
|
|
||||||
|
|
||||||
return (result);
|
return (kore_malloc(memb * len));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue