[geos-commits] [SCM] GEOS branch master updated. 96041d28f472ad759a50913bd9fbf55be5d18d91

git at osgeo.org git at osgeo.org
Sat Aug 18 10:07:22 PDT 2018


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  96041d28f472ad759a50913bd9fbf55be5d18d91 (commit)
       via  ae8a2d31dcfe5c7a60c9e48bdd66886f95aa5772 (commit)
      from  3db733ddd1b6c4c407561023291cd648741ea79d (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 96041d28f472ad759a50913bd9fbf55be5d18d91
Merge: 3db733d ae8a2d3
Author: Daniel Baston <dbaston at gmail.com>
Date:   Sat Aug 18 13:06:28 2018 -0400

    Merge branch 'trac-730'


commit ae8a2d31dcfe5c7a60c9e48bdd66886f95aa5772
Author: Daniel Baston <dbaston at gmail.com>
Date:   Mon Aug 13 19:11:30 2018 -0400

    Avoid segfault when querying empty tree
    
    Closes #730
    Closes https://github.com/libgeos/geos/pull/116

diff --git a/src/index/strtree/AbstractSTRtree.cpp b/src/index/strtree/AbstractSTRtree.cpp
index 44d73f3..12fa521 100644
--- a/src/index/strtree/AbstractSTRtree.cpp
+++ b/src/index/strtree/AbstractSTRtree.cpp
@@ -125,7 +125,10 @@ AbstractSTRtree::query(const void* searchBounds, vector<void*>& matches)
 {
 	if (!built) build();
 
-	if (itemBoundables->empty()) assert(root->getBounds()==nullptr);
+	if (itemBoundables->empty()) {
+		assert(root->getBounds()==nullptr);
+		return;
+	}
 
 	if (getIntersectsOp()->intersects(root->getBounds(), searchBounds))
 	{
@@ -139,7 +142,10 @@ AbstractSTRtree::query(const void* searchBounds, ItemVisitor& visitor)
 {
 	if (!built) build();
 
-	if (itemBoundables->empty()) assert(root->getBounds()==nullptr);
+	if (itemBoundables->empty()) {
+        assert(root->getBounds()==nullptr);
+        return;
+	}
 
 	if (getIntersectsOp()->intersects(root->getBounds(),searchBounds))
 	{
diff --git a/tests/unit/capi/GEOSSTRtreeTest.cpp b/tests/unit/capi/GEOSSTRtreeTest.cpp
index a3f6293..72989c5 100644
--- a/tests/unit/capi/GEOSSTRtreeTest.cpp
+++ b/tests/unit/capi/GEOSSTRtreeTest.cpp
@@ -230,6 +230,21 @@ namespace tut
 		GEOSSTRtree_destroy(tree);
 	}
 
+	// querying empty tree should not crash (see #730)
+    template<>
+    template<>
+    void object::test<7>() {
+	    GEOSSTRtree* tree = GEOSSTRtree_create(16);
+	    GEOSGeometry* q = GEOSGeomFromWKT("POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))");
+	    GEOSSTRtree_query(tree, q, [](void* item, void* userdata) {
+	   		assert(item); // make unused parameter warning go away
+			assert(userdata);
+        }, nullptr);
+
+		GEOSGeom_destroy(q);
+		GEOSSTRtree_destroy(tree);
+	}
+
 } // namespace tut
 
 

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

Summary of changes:
 src/index/strtree/AbstractSTRtree.cpp | 10 ++++++++--
 tests/unit/capi/GEOSSTRtreeTest.cpp   | 15 +++++++++++++++
 2 files changed, 23 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list