Fix Stack Overflow When Nesting Clipper2 Results With Cyclic Splits (#17592)

Backport PolyClipping/Clipper2 f97d65d. CheckSplitOwner descended into an
emptied OutRec's splits without the recursive_split guard, so emptied
OutRecs that referred to each other recursed until the stack overflowed.

Fixes #17584
This commit is contained in:
TheLegendTubaGuy authored and GitHub committed 2026-11-20 22:07:36 -06:00
1 parent ced396fedc
commit 49b84637ee
2 files changed
+16 -2

No files matched your search

@@ -2978,8 +2978,14 @@ namespace Clipper2Lib {
for (size_t idx = 0; idx < splits->size(); ++idx)
{
OutRec* split = (*splits)[idx];
if (!split->pts && split->splits &&
CheckSplitOwner(outrec, split->splits)) return true; //#942
if (!split->pts && split->splits)
{
if (split->recursive_split == outrec) continue;
split->recursive_split = outrec; // emptied OutRecs can reference each other
if (CheckSplitOwner(outrec, split->splits)) return true; //#942
}
split = GetRealOutRec(split);
if (!split || split == outrec || split->recursive_split == outrec) continue;
split->recursive_split = outrec; // prevent infinite loops