Revert incorrect parameter validation

This commit is contained in:
Stig Telfer 2015-12-29 21:29:35 +00:00
parent 0c51d9da53
commit ac45e8cd62
1 changed files with 3 additions and 10 deletions

View File

@ -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