[geos-commits] [SCM] GEOS branch 3.8 updated. 798b6e79ca4bf257757f4fec09c6d41729da27e6

git at osgeo.org git at osgeo.org
Mon Mar 8 16:58:59 PST 2021


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, 3.8 has been updated
       via  798b6e79ca4bf257757f4fec09c6d41729da27e6 (commit)
       via  63c7f6c42ceee33a5553ca32c3b79fd252adcf73 (commit)
      from  70906a91f58a26bbd2a0c25140a8d88459abfc54 (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 798b6e79ca4bf257757f4fec09c6d41729da27e6
Author: Daniel Baston <dbaston at gmail.com>
Date:   Mon Mar 8 19:58:36 2021 -0500

    Add NEWS entry

diff --git a/NEWS b/NEWS
index dc7a06d..de3b7af 100644
--- a/NEWS
+++ b/NEWS
@@ -16,7 +16,8 @@ Changes in 3.8.2dev
   - Fix GEOSProjectNormalized return -1 on exception (#1058, Joris Van den Bossche)
   - Fix memory management quirk in CAPI (#1050, Paul Ramsey)
   - Allow build on Apple ARM64 (Taras Zakharko)
-
+  - Fix crash in GEOSPreparedIntersects and GEOSPreparedContains for
+    POINT EMPTY input (Even Rouault)
 
 Changes in 3.8.1
 2020-03-10

commit 63c7f6c42ceee33a5553ca32c3b79fd252adcf73
Author: Even Rouault <even.rouault at spatialys.com>
Date:   Mon Mar 8 16:51:00 2021 +0100

    Fix crash with GEOSPreparedIntersects/Covers on a POINT EMPTY
    
    Fixes use case spotted by https://github.com/OSGeo/gdal/issues/3542#issuecomment-792659437

diff --git a/src/geom/prep/BasicPreparedGeometry.cpp b/src/geom/prep/BasicPreparedGeometry.cpp
index 65fca75..73f0581 100644
--- a/src/geom/prep/BasicPreparedGeometry.cpp
+++ b/src/geom/prep/BasicPreparedGeometry.cpp
@@ -41,7 +41,11 @@ bool
 BasicPreparedGeometry::envelopesIntersect(const geom::Geometry* g) const
 {
     if (g->getGeometryTypeId() == GEOS_POINT) {
-        return baseGeom->getEnvelopeInternal()->intersects(*(g->getCoordinate()));
+        auto pt = g->getCoordinate();
+        if (pt == nullptr) {
+            return false;
+        }
+        return baseGeom->getEnvelopeInternal()->intersects(*pt);
     }
 
     return baseGeom->getEnvelopeInternal()->intersects(g->getEnvelopeInternal());
@@ -51,7 +55,11 @@ bool
 BasicPreparedGeometry::envelopeCovers(const geom::Geometry* g) const
 {
     if (g->getGeometryTypeId() == GEOS_POINT) {
-        return baseGeom->getEnvelopeInternal()->covers(g->getCoordinate());
+        auto pt = g->getCoordinate();
+        if (pt == nullptr) {
+            return false;
+        }
+        return baseGeom->getEnvelopeInternal()->covers(pt);
     }
 
     return baseGeom->getEnvelopeInternal()->covers(g->getEnvelopeInternal());
diff --git a/tests/unit/capi/GEOSPreparedGeometryTest.cpp b/tests/unit/capi/GEOSPreparedGeometryTest.cpp
index ca760b9..8d3b888 100644
--- a/tests/unit/capi/GEOSPreparedGeometryTest.cpp
+++ b/tests/unit/capi/GEOSPreparedGeometryTest.cpp
@@ -392,5 +392,40 @@ void object::test<11>
         ensure_equals(ret, 0);
     }
 }
+
+// Test PreparedIntersects with Point EMPTY
+template<>
+template<>
+void object::test<12>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))");
+    geom2_ = GEOSGeomFromWKT("POINT EMPTY");
+    prepGeom1_ = GEOSPrepare(geom1_);
+
+    ensure(nullptr != prepGeom1_);
+    ensure(nullptr != geom2_);
+
+    int ret = GEOSPreparedIntersects(prepGeom1_, geom2_);
+    ensure_equals(ret, 0);
+}
+
+// Test PreparedCovers with Point EMPTY
+template<>
+template<>
+void object::test<13>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))");
+    geom2_ = GEOSGeomFromWKT("POINT EMPTY");
+    prepGeom1_ = GEOSPrepare(geom1_);
+
+    ensure(nullptr != prepGeom1_);
+    ensure(nullptr != geom2_);
+
+    int ret = GEOSPreparedCovers(prepGeom1_, geom2_);
+    ensure_equals(ret, 0);
+}
+
 } // namespace tut
 

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

Summary of changes:
 NEWS                                         |  3 ++-
 src/geom/prep/BasicPreparedGeometry.cpp      | 12 ++++++++--
 tests/unit/capi/GEOSPreparedGeometryTest.cpp | 35 ++++++++++++++++++++++++++++
 3 files changed, 47 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list