mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-20 23:00:56 -05:00
Do not divide by zero.
git-svn-id: file:///svn/unbound/trunk@3374 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
383e32f02f
commit
cd2e99dafd
1 changed files with 2 additions and 2 deletions
|
|
@ -369,7 +369,7 @@ void *unbound_stat_calloc(size_t nmemb, size_t size)
|
||||||
{
|
{
|
||||||
size_t s;
|
size_t s;
|
||||||
void* res;
|
void* res;
|
||||||
if(INT_MAX/nmemb < size)
|
if(nmemb != 0 && INT_MAX/nmemb < size)
|
||||||
return NULL; /* integer overflow check */
|
return NULL; /* integer overflow check */
|
||||||
s = (nmemb*size==0)?(size_t)1:nmemb*size;
|
s = (nmemb*size==0)?(size_t)1:nmemb*size;
|
||||||
res = calloc(1, s+16);
|
res = calloc(1, s+16);
|
||||||
|
|
@ -509,7 +509,7 @@ void *unbound_stat_calloc_lite(size_t nmemb, size_t size, const char* file,
|
||||||
{
|
{
|
||||||
size_t req;
|
size_t req;
|
||||||
void* res;
|
void* res;
|
||||||
if(INT_MAX/nmemb < size)
|
if(nmemb != 0 && INT_MAX/nmemb < size)
|
||||||
return NULL; /* integer overflow check */
|
return NULL; /* integer overflow check */
|
||||||
req = nmemb * size;
|
req = nmemb * size;
|
||||||
res = malloc(req+lite_pad*2+sizeof(size_t));
|
res = malloc(req+lite_pad*2+sizeof(size_t));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue