diff options
author | Chris Robinson <[email protected]> | 2017-12-17 14:30:51 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2017-12-17 14:30:51 -0800 |
commit | 57e516720e6e91978360853ee37c2bbb28fbdc8f (patch) | |
tree | 998cb1eaa48acf5a90bacb2edd8452a3e7e71512 /utils | |
parent | d229afb83da8d944a8219d6efe351b510fdaec00 (diff) |
Avoid a potential calloc of 0
Diffstat (limited to 'utils')
-rw-r--r-- | utils/makehrtf.c | 11 |
1 files 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; |