[geos-commits] [SCM] GEOS branch main updated. 6e15c6ca1f948d18745e54b7e4ef121a205fda9a

git at osgeo.org git at osgeo.org
Mon Feb 5 11:15:02 PST 2024


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GEOS".

The branch, main has been updated
       via  6e15c6ca1f948d18745e54b7e4ef121a205fda9a (commit)
      from  8d87edcd51653b47ca955cc3a9ac744f41988d92 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 6e15c6ca1f948d18745e54b7e4ef121a205fda9a
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Mon Feb 5 11:14:27 2024 -0800

    Fix segfault when coverage simplify called with nonpolygons, references GH-1031 (#1039)

diff --git a/src/coverage/CoverageSimplifier.cpp b/src/coverage/CoverageSimplifier.cpp
index 73b5a5e44..335b10759 100644
--- a/src/coverage/CoverageSimplifier.cpp
+++ b/src/coverage/CoverageSimplifier.cpp
@@ -20,6 +20,7 @@
 #include <geos/geom/Geometry.h>
 #include <geos/geom/GeometryFactory.h>
 #include <geos/geom/MultiLineString.h>
+#include <geos/util/IllegalArgumentException.h>
 
 
 using geos::geom::Geometry;
@@ -83,7 +84,12 @@ CoverageSimplifier::simplifyInner(
 CoverageSimplifier::CoverageSimplifier(std::vector<const Geometry*>& coverage)
     : m_input(coverage)
     , m_geomFactory(coverage.empty() ? nullptr : coverage[0]->getFactory())
-    {}
+    {
+        for (const Geometry* g: m_input) {
+            if (!g->isPolygonal())
+                throw util::IllegalArgumentException("Argument is not a non-polygonal");
+        }
+    }
 
 /* public */
 std::vector<std::unique_ptr<Geometry>>
diff --git a/tests/unit/coverage/CoverageSimplifierTest.cpp b/tests/unit/coverage/CoverageSimplifierTest.cpp
index 61e79f54e..94534544a 100644
--- a/tests/unit/coverage/CoverageSimplifierTest.cpp
+++ b/tests/unit/coverage/CoverageSimplifierTest.cpp
@@ -431,7 +431,7 @@ void object::test<24> ()
             "POLYGON EMPTY",
             "POLYGON EMPTY" })
     );
-  }
+}
 
 // testOneEmpty
 template<>
@@ -446,7 +446,7 @@ void object::test<25> ()
             "POLYGON ((1 9, 9 9, 9 1, 1 1, 1 9))",
             "POLYGON EMPTY" })
     );
-  }
+}
 
 // testEmptyHole()
 template<>
@@ -461,6 +461,26 @@ void object::test<26> ()
             "POLYGON ((1 9, 9 9, 9 1, 1 1, 1 9), EMPTY)",
             "POLYGON EMPTY" })
     );
-  }
+}
+
+// Test non-polygon inputs (GH-1031)
+template<>
+template<>
+void object::test<30> ()
+{
+    auto input = readArray({
+        "MULTILINESTRING ((200 100, 100 100, 200 200), (200 200, 200 100), (200 200, 300 100, 200 100))"
+        });
+    try {
+        std::vector<std::unique_ptr<Geometry>> result =
+        CoverageSimplifier::simplify(input, 10);
+    }
+    catch (geos::util::IllegalArgumentException& iae) {
+        ensure("caught IllegalArgumentException", true);
+        return;
+    }
+    ensure("did not throw IllegalArgumentException", false);
+}
+
 
 } // namespace tut

-----------------------------------------------------------------------

Summary of changes:
 src/coverage/CoverageSimplifier.cpp            |  8 +++++++-
 tests/unit/coverage/CoverageSimplifierTest.cpp | 26 +++++++++++++++++++++++---
 2 files changed, 30 insertions(+), 4 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list