Skip to content

Commit 43929cf

Browse files
committed
fix froll memory leaks #7273
1 parent 227b39e commit 43929cf

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/froll.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,7 @@ void frollmaxExact(double *x, uint64_t nx, ans_t *ans, int k, double fill, bool
681681
ans->dbl_v[i] = w;
682682
}
683683
}
684+
free(isnan);
684685
}
685686
}
686687

@@ -841,7 +842,6 @@ void frollminExact(double *x, uint64_t nx, ans_t *ans, int k, double fill, bool
841842
bool *isnan = malloc(nx*sizeof(bool)); // isnan lookup - we use it to reduce ISNAN calls in nested loop
842843
if (!isnan) { // # nocov start
843844
ansSetMsg(ans, 3, "%s: Unable to allocate memory for isnan", __func__); // raise error
844-
free(isnan);
845845
return;
846846
} // # nocov end
847847
bool truehasnf = hasnf>0;
@@ -885,6 +885,7 @@ void frollminExact(double *x, uint64_t nx, ans_t *ans, int k, double fill, bool
885885
ans->dbl_v[i] = w;
886886
}
887887
}
888+
free(isnan);
888889
}
889890
}
890891

src/frolladaptive.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ void frolladaptivemaxExact(double *x, uint64_t nx, ans_t *ans, int *k, double fi
554554
}
555555
}
556556
}
557+
free(isnan);
557558
}
558559
}
559560

@@ -581,7 +582,6 @@ void frolladaptiveminExact(double *x, uint64_t nx, ans_t *ans, int *k, double fi
581582
bool *isnan = malloc(nx*sizeof(bool)); // isnan lookup - we use it to reduce ISNAN calls in nested loop
582583
if (!isnan) { // # nocov start
583584
ansSetMsg(ans, 3, "%s: Unable to allocate memory for isnan", __func__); // raise error
584-
free(isnan);
585585
return;
586586
} // # nocov end
587587
bool truehasnf = hasnf>0;
@@ -633,6 +633,7 @@ void frolladaptiveminExact(double *x, uint64_t nx, ans_t *ans, int *k, double fi
633633
}
634634
}
635635
}
636+
free(isnan);
636637
}
637638
}
638639

0 commit comments

Comments
 (0)