diff --git a/src/connect_edges.js b/src/connect_edges.js index 92dba4c..1a4f239 100644 --- a/src/connect_edges.js +++ b/src/connect_edges.js @@ -75,7 +75,8 @@ function nextPos(pos, resultEvents, processed, origIndex) { } else { newPos++; } - p1 = resultEvents[newPos].point; + if (newPos < length) + p1 = resultEvents[newPos].point; } newPos = pos - 1;