Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/algs/cdirect/cdirect.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ static nlopt_result divide_rect(double *rdiv, params *p)
rnew[3 + isort[i]] += w[isort[i]] * (2*k-1);
rnew[1] = fv[2*isort[i]+k];
rnew[2] = p->age++;
if (!isfinite(rnew[1])) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably this check could have happened before rnew was allocated.... also would have been nice to match the surrounding indenting

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, done

free(rnew);
return NLOPT_FAILURE;
}
if (!nlopt_rb_tree_insert(&p->rtree, rnew)) {
free(rnew);
return NLOPT_OUT_OF_MEMORY;
Expand Down Expand Up @@ -233,6 +237,10 @@ static nlopt_result divide_rect(double *rdiv, params *p)
rnew[3 + i] += w[i] * (2*k-1);
FUNCTION_EVAL(rnew[1], rnew + 3, p, rnew);
rnew[2] = p->age++;
if (!isfinite(rnew[1])) {
free(rnew);
return NLOPT_FAILURE;
}
if (!nlopt_rb_tree_insert(&p->rtree, rnew)) {
free(rnew);
return NLOPT_OUT_OF_MEMORY;
Expand Down
Loading