Skip to content

Commit 71ae512

Browse files
committed
Add workaround to prevent an infinite loop in aCutes GetStarPoints method.
See #58
1 parent 70aafe3 commit 71ae512

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/Triangle/NewLocation.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ class NewLocation
2222
{
2323
const double EPS = 1e-50;
2424

25+
// A safeguard to prevent an infinite loop in GetStarPoints method, see
26+
// https://github.com/wo80/Triangle.NET/issues/58
27+
const int GETSTARPOINTS_SAFEGUARD = 2000;
28+
2529
IPredicates predicates;
2630

2731
Mesh mesh;
@@ -2306,6 +2310,12 @@ private int GetStarPoints(Otri badotri, Vertex p, Vertex q, Vertex r,
23062310
break;
23072311
}
23082312

2313+
if (numvertices > GETSTARPOINTS_SAFEGUARD)
2314+
{
2315+
numvertices = 0;
2316+
break;
2317+
}
2318+
23092319
} while (!((Math.Abs(returnPoint[0] - third_x) <= EPS) &&
23102320
(Math.Abs(returnPoint[1] - third_y) <= EPS)));
23112321
return numvertices / 2;

0 commit comments

Comments
 (0)