Skip to content

Commit

Permalink
Patch a case where nodes with very close to zero values created an in…
Browse files Browse the repository at this point in the history
…finite alloc loop. (#8388)

The situation arose when the condition

if ((dz = z[this_side] - z[this_side+1]) == 0.0f) continue;

was never met by a tiny bit. Comparing to 0.0 is never a good idea. So I made it

if (fabs((dz = z[this_side] - z[this_side+1])) < 1e-10) continue;

I get 6 grdcontour test failures but they don't seem related to this change (more due to the endless headache of slight different grids).

Fixes #8387
  • Loading branch information
joa-quim committed Mar 4, 2024
1 parent dbe4617 commit 2bec117
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/gmt_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -2646,11 +2646,10 @@ GMT_LOCAL uint64_t gmtsupport_trace_contour (struct GMT_CTRL *GMT, struct GMT_GR
n_nan++;
continue;
}

/* Skip if no zero-crossing on this edge */

if (z[this_side+1] * z[this_side] > 0.0f) continue;
if ((dz = z[this_side] - z[this_side+1]) == 0.0f) continue;
if (fabs((dz = z[this_side] - z[this_side+1])) < 1e-10) continue;

/* Save normalized distance along edge from corner this_side to crossing of edge this_side */

Expand Down

0 comments on commit 2bec117

Please sign in to comment.