Skip to content

Commit

Permalink
Avoid crashing if there is a polygon ring containing only one point (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
e-n-f authored May 11, 2023
1 parent 523ca55 commit 20eb9c8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 2.26.1

* Avoid crashing if there is a polygon ring with only one point

# 2.26.0

* Fix bugs in --no-simplification-of-shared-nodes
Expand Down
10 changes: 10 additions & 0 deletions geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion version.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef VERSION_HPP
#define VERSION_HPP

#define VERSION "v2.26.0"
#define VERSION "v2.26.1"

#endif

0 comments on commit 20eb9c8

Please sign in to comment.