diff --git a/NEWS.md b/NEWS.md index f9b07564b0..466f06001f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,6 +7,7 @@ - GEOSRelatePatternMatch: Fix crash on invalid DE-9IM pattern (GH-1089, Dan Baston) - Port TopologyPreservingSimplifier fixes (GH-986, GH-1107, GH-857, GH-784, GH-1070, Paul Ramsey) - Fix ConcaveHullOfPolygons nested shell handling (GH-1169, Martin Davis) + - GEOSConcaveHullOfPolygons, Avoid crash on zero-area input (GH-1071, Dan Baston) ## Changes in 3.11.4 2024-06-05 diff --git a/src/algorithm/hull/ConcaveHullOfPolygons.cpp b/src/algorithm/hull/ConcaveHullOfPolygons.cpp index 623a7662ab..d49b5eff1e 100644 --- a/src/algorithm/hull/ConcaveHullOfPolygons.cpp +++ b/src/algorithm/hull/ConcaveHullOfPolygons.cpp @@ -154,7 +154,7 @@ ConcaveHullOfPolygons::setTight(bool p_isTight) std::unique_ptr ConcaveHullOfPolygons::getHull() { - if (inputPolygons->isEmpty()) { + if (inputPolygons->isEmpty() || inputPolygons->getArea() == 0) { return createEmptyHull(); } buildHullTris(); diff --git a/tests/unit/capi/GEOSConcaveHullOfPolygonsTest.cpp b/tests/unit/capi/GEOSConcaveHullOfPolygonsTest.cpp index a5a485e9de..16a80299a0 100644 --- a/tests/unit/capi/GEOSConcaveHullOfPolygonsTest.cpp +++ b/tests/unit/capi/GEOSConcaveHullOfPolygonsTest.cpp @@ -54,6 +54,15 @@ void object::test<2>() ensure_geometry_equals(geom1_, expected_); } +template<> +template<> +void object::test<4>() +{ + input_ = fromWKT("POLYGON((0 0, 0 0, 0 0))"); + result_ = GEOSConcaveHullOfPolygons(input_, 0.7, false, false); + ensure(GEOSisEmpty(result_)); +} + } // namespace tut