diff --git a/src/froll.c b/src/froll.c index 6d4bdad44e..5b36cb27d2 100644 --- a/src/froll.c +++ b/src/froll.c @@ -681,6 +681,7 @@ void frollmaxExact(const double *x, uint64_t nx, ans_t *ans, int k, double fill, ans->dbl_v[i] = w; } } + free(isnan); } } @@ -841,7 +842,6 @@ void frollminExact(const double *x, uint64_t nx, ans_t *ans, int k, double fill, bool *isnan = malloc(sizeof(*isnan) * nx); // isnan lookup - we use it to reduce ISNAN calls in nested loop if (!isnan) { // # nocov start ansSetMsg(ans, 3, "%s: Unable to allocate memory for isnan", __func__); // raise error - free(isnan); return; } // # nocov end bool truehasnf = hasnf>0; @@ -885,6 +885,7 @@ void frollminExact(const double *x, uint64_t nx, ans_t *ans, int k, double fill, ans->dbl_v[i] = w; } } + free(isnan); } } diff --git a/src/frolladaptive.c b/src/frolladaptive.c index 7f67e78fce..c9078dae5a 100644 --- a/src/frolladaptive.c +++ b/src/frolladaptive.c @@ -554,6 +554,7 @@ void frolladaptivemaxExact(const double *x, uint64_t nx, ans_t *ans, const int * } } } + free(isnan); } } @@ -581,7 +582,6 @@ void frolladaptiveminExact(const double *x, uint64_t nx, ans_t *ans, const int * bool *isnan = malloc(sizeof(*isnan) * nx); // isnan lookup - we use it to reduce ISNAN calls in nested loop if (!isnan) { // # nocov start ansSetMsg(ans, 3, "%s: Unable to allocate memory for isnan", __func__); // raise error - free(isnan); return; } // # nocov end bool truehasnf = hasnf>0; @@ -633,6 +633,7 @@ void frolladaptiveminExact(const double *x, uint64_t nx, ans_t *ans, const int * } } } + free(isnan); } } @@ -647,7 +648,6 @@ void frolladaptiveprodFast(const double *x, uint64_t nx, ans_t *ans, const int * double *cs = malloc(sizeof(*cs) * nx); if (!cs) { // # nocov start ansSetMsg(ans, 3, "%s: Unable to allocate memory for cumprod", __func__); // raise error - free(cs); return; } // # nocov end if (!truehasnf) { @@ -679,19 +679,19 @@ void frolladaptiveprodFast(const double *x, uint64_t nx, ans_t *ans, const int * uint64_t *cn = malloc(sizeof(*cn) * nx); // cumulative NA counter, used the same way as cumprod, same as uint64_t cn[nx] but no segfault if (!cn) { // # nocov start ansSetMsg(ans, 3, "%s: Unable to allocate memory for cum NA counter", __func__); // raise error - free(cs); free(cn); + free(cs); return; } // # nocov end uint64_t *cpinf = malloc(sizeof(*cpinf) * nx); if (!cpinf) { // # nocov start ansSetMsg(ans, 3, "%s: Unable to allocate memory for cum Inf counter", __func__); // raise error - free(cs); free(cn); free(cpinf); + free(cs); free(cn); return; } // # nocov end uint64_t *cninf = malloc(sizeof(*cninf) * nx); if (!cninf) { // # nocov start ansSetMsg(ans, 3, "%s: Unable to allocate memory for cum -Inf counter", __func__); // raise error - free(cs); free(cn); free(cpinf); free(cninf); + free(cs); free(cn); free(cpinf); return; } // # nocov end for (uint64_t i=0; i