Avoid crashing if there is a polygon ring containing only one point (#102)

This commit is contained in:
Erica Fischer
2023-05-11 12:20:00 -07:00
committed by GitHub
parent 523ca55243
commit 20eb9c8dae
3 changed files with 15 additions and 1 deletions
+10
View File
@@ -1049,6 +1049,16 @@ drawvec fix_polygon(drawvec &geom) {
}
}
// A polygon ring must contain at least three points
// (and really should contain four). If this one does
// not have enough, avoid a division by zero trying to
// calculate the centroid below.
if (j - i < 3) {
i = j - 1;
outer = 0;
continue;
}
// Make a temporary copy of the ring.
// Close it if it isn't closed.