Skip to content

Commit

Permalink
DouglasPeuckerLineSimplifier: Avoid crash with Point input and NaN to…
Browse files Browse the repository at this point in the history
…lerance

Fixes libgeos#1078
  • Loading branch information
dbaston committed Jun 19, 2024
1 parent a690eb6 commit 17f63c8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/simplify/DouglasPeuckerLineSimplifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ DouglasPeuckerLineSimplifier::simplifySection(
std::size_t i,
std::size_t j)
{
if((i + 1) == j) {
if(/*i == j || */(i + 1) == j) {
return;
}

Expand Down
11 changes: 11 additions & 0 deletions tests/unit/simplify/DouglasPeuckerSimplifierTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,4 +334,15 @@ void object::test<19>()
);
}

// https://github.com/libgeos/geos/issues/1078
template<>
template<>
void object::test<20>()
{
auto gfact = GeometryFactory::getDefaultInstance();
auto pt = gfact->createPoint(Coordinate{0, 0});
auto result = DouglasPeuckerSimplifier::simplify(pt.get(), std::numeric_limits<double>::quiet_NaN());
ensure(result != nullptr);
}

} // namespace tut

0 comments on commit 17f63c8

Please sign in to comment.