Skip to content

Commit 78e6480

Browse files
committed
e6d2ac1 Fixed infinite loop bug
1 parent dc929e0 commit 78e6480

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/main/java/clipper2/engine/ClipperBase.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,6 +2130,7 @@ else if ((isLeftToRight && (TopX(ae, pt.y) >= pt.x)) || (!isLeftToRight && (TopX
21302130
if (IsHotEdge(horz)) {
21312131
AddOutPt(horz, horz.top);
21322132
}
2133+
21332134
UpdateEdgeIntoAEL(horz);
21342135

21352136
if (getPreserveCollinear() && !horzIsOpen && HorzIsSpike(horz)) {
@@ -2145,7 +2146,8 @@ else if ((isLeftToRight && (TopX(ae, pt.y) >= pt.x)) || (!isLeftToRight && (TopX
21452146
} // end for loop and end of (possible consecutive) horizontals
21462147

21472148
if (IsHotEdge(horz)) {
2148-
AddOutPt(horz, horz.top);
2149+
OutPt op = AddOutPt(horz, horz.top);
2150+
AddToHorzSegList(op);
21492151
}
21502152
UpdateEdgeIntoAEL(horz); // this is the end of an intermediate horiz.
21512153
}
@@ -2421,10 +2423,8 @@ private void ConvertHorzSegsToJoins() {
24212423
// for each HorzSegment, find others that overlap
24222424
for (int j = i + 1; j < k; j++) {
24232425
HorzSegment hs2 = horzSegList.get(j);
2424-
if (hs2.leftOp.pt.x >= hs1.rightOp.pt.x) {
2425-
break;
2426-
}
2427-
if (hs2.leftToRight == hs1.leftToRight || (hs2.rightOp.pt.x <= hs1.leftOp.pt.x)) {
2426+
if ((hs2.leftOp.pt.x >= hs1.rightOp.pt.x) || (hs2.leftToRight == hs1.leftToRight)
2427+
|| (hs2.rightOp.pt.x <= hs1.leftOp.pt.x)) {
24282428
continue;
24292429
}
24302430
long currY = hs1.leftOp.pt.y;
@@ -2612,8 +2612,7 @@ private void ProcessHorzJoins() {
26122612
or1.splits.add(or2.idx); // (#498)
26132613
or2.owner = or1;
26142614
}
2615-
}
2616-
else {
2615+
} else {
26172616
or2.owner = or1;
26182617
}
26192618
outrecList.add(or2); // NOTE removed in 6e15ba0, but then fails tests
@@ -2883,11 +2882,12 @@ private boolean CheckSplitOwner(OutRec outrec, List<Integer> splits) {
28832882
if (outrec.owner == null || outrec.owner.splits == null) {
28842883
return false;
28852884
}
2886-
for (int i : outrec.owner.splits) {
2885+
for (int i : splits) {
28872886
OutRec split = outrecList.get(i);
28882887
if (split == outrec || split == outrec.owner) {
28892888
continue;
2890-
} else if (split.splits != null && CheckSplitOwner(outrec, split.splits)) {
2889+
}
2890+
if (split.splits != null && CheckSplitOwner(outrec, split.splits)) {
28912891
return true;
28922892
}
28932893
if (CheckBounds(split) && split.bounds.Contains(outrec.bounds) && Path1InsidePath2(outrec.pts, split.pts)) {

0 commit comments

Comments
 (0)