From 57e516720e6e91978360853ee37c2bbb28fbdc8f Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 17 Dec 2017 14:30:51 -0800 Subject: Avoid a potential calloc of 0 --- utils/makehrtf.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/utils/makehrtf.c b/utils/makehrtf.c index 461df597..417b9944 100644 --- a/utils/makehrtf.c +++ b/utils/makehrtf.c @@ -965,9 +965,7 @@ static double *CreateDoubles(size_t n) { double *a; - if(n == 0) - n = 1; - a = calloc(n, sizeof(*a)); + a = calloc(n?n:1, sizeof(*a)); if(a == NULL) { fprintf(stderr, "Error: Out of memory.\n"); @@ -981,9 +979,7 @@ static Complex *CreateComplexes(size_t n) { Complex *a; - if(n == 0) - n = 1; - a = calloc(n, sizeof(*a)); + a = calloc(n?n:1, sizeof(*a)); if(a == NULL) { fprintf(stderr, "Error: Out of memory.\n"); @@ -2564,6 +2560,9 @@ static int PrepareHrirData(const uint fdCount, const double distances[MAX_FD_COU for(ei = 0;ei < evCounts[fi];ei++) azTotal += azCounts[(fi * MAX_EV_COUNT) + ei]; } + if(!fdCount || !evTotal || !azTotal) + return 0; + hData->mFds = calloc(fdCount, sizeof(*hData->mFds)); if(hData->mFds == NULL) return 0; -- cgit v1.2.3