[geos-commits] [SCM] GEOS branch master updated. 1539ef17c42541ffb0d69b56ba80a03618bafdc2

git at osgeo.org git at osgeo.org
Mon Nov 2 06:19:20 PST 2020


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, master has been updated
       via  1539ef17c42541ffb0d69b56ba80a03618bafdc2 (commit)
      from  708d32b2cd2dd3bedc38ff1d839368656b1f9626 (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 1539ef17c42541ffb0d69b56ba80a03618bafdc2
Author: Sandro Santilli <strk at kbt.io>
Date:   Mon Nov 2 12:25:11 2020 +0100

    Avoid crash from IndexedFacetDistance with empty input
    
    Closes #1065
    Include test

diff --git a/src/operation/distance/FacetSequenceTreeBuilder.cpp b/src/operation/distance/FacetSequenceTreeBuilder.cpp
index 7ce3e8a..b737810 100644
--- a/src/operation/distance/FacetSequenceTreeBuilder.cpp
+++ b/src/operation/distance/FacetSequenceTreeBuilder.cpp
@@ -73,6 +73,7 @@ FacetSequenceTreeBuilder::addFacetSequences(const Geometry* geom, const Coordina
 {
     size_t i = 0;
     size_t size = pts->size();
+    if ( size == 0 ) return;
 
     while(i <= size - 1) {
         size_t end = i + FACET_SEQUENCE_SIZE + 1;
diff --git a/tests/unit/operation/distance/IndexedFacetDistanceTest.cpp b/tests/unit/operation/distance/IndexedFacetDistanceTest.cpp
index aed155a..b2e0a08 100644
--- a/tests/unit/operation/distance/IndexedFacetDistanceTest.cpp
+++ b/tests/unit/operation/distance/IndexedFacetDistanceTest.cpp
@@ -11,6 +11,7 @@
 
 // tut
 #include <tut/tut.hpp>
+#include <tut/tut_macros.hpp>
 // geos
 #include <geos/profiler.h>
 #include <geos/constants.h>
@@ -26,6 +27,7 @@
 #include <geos/io/WKTWriter.h>
 #include <geos/operation/distance/DistanceOp.h>
 #include <geos/operation/distance/IndexedFacetDistance.h>
+#include <geos/util/GEOSException.h>
 
 #ifndef M_PI
 #define M_PI 3.14159265358979323846
@@ -336,6 +338,34 @@ void object::test<10>
     }
 }
 
+// EMPTY polygon
+template<>
+template<>
+void object::test<11>
+()
+{
+    using geos::operation::distance::IndexedFacetDistance;
+    using geos::util::GEOSException;
+
+    std::string wkt0("POLYGON EMPTY");
+    std::string wkt1("POINT(150 150)");
+    GeomPtr g0(_wktreader.read(wkt0));
+    GeomPtr g1(_wktreader.read(wkt1));
+    IndexedFacetDistance ifd(g0.get());
+
+    try {
+        ifd.distance(g1.get());
+        fail("IndexedFacedDistance::distance did not throw on empty input");
+    }
+    catch (const GEOSException&) { }
+
+    try {
+        ifd.nearestPoints(g1.get());
+        fail("IndexedFacedDistance::nearestPoints did not throw on empty input");
+    }
+    catch (const GEOSException&) { }
+}
+
 
 
 // TODO: finish the tests by adding:

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

Summary of changes:
 .../distance/FacetSequenceTreeBuilder.cpp          |  1 +
 .../distance/IndexedFacetDistanceTest.cpp          | 30 ++++++++++++++++++++++
 2 files changed, 31 insertions(+)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list