Skip to content

Commit

Permalink
RepeatedPointRemover: Avoid reading invalidated reference (#762)
Browse files Browse the repository at this point in the history
Fixes #759
  • Loading branch information
dbaston committed Dec 8, 2022
1 parent e692362 commit d463bcb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/operation/valid/RepeatedPointRemover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,14 @@ class RepeatedPointCoordinateOperation : public CoordinateOperation

// End points for comparison and sequence repair
const Coordinate& origEndCoord = coordinates->back();
const Coordinate& filtEndCoord = filtCoords->back();

// Fluff up overly small filtered outputs
if(filtCoords->size() < minLength) {
filtCoords->add(origEndCoord);
}

const Coordinate& filtEndCoord = filtCoords->back();

// We stripped the last point, let's put it back on
if (!origEndCoord.equals2D(filtEndCoord)) {
// If the end of the filtered coordinates is within
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/capi/GEOSRemoveRepeatedPointsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ void object::test<1>
ensure_geometry_equals(geom2_, expected_);
}

// https://github.com/libgeos/geos/issues/759
template<>
template<>
void object::test<2>
()
{
geom1_ = GEOSGeomFromWKT("POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))");
result_ = GEOSRemoveRepeatedPoints(geom1_, 2.0);

ensure(result_ == nullptr);
}


} // namespace tut

0 comments on commit d463bcb

Please sign in to comment.