[geos-commits] [SCM] GEOS branch main updated. 7e3fd04eda8706c227b73ddd09e4d104c7c8fb5a
git at osgeo.org
git at osgeo.org
Wed Jul 16 14:52:21 PDT 2025
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 7e3fd04eda8706c227b73ddd09e4d104c7c8fb5a (commit)
from ded33834934a547ecfd3a885f096bfcb2e2b8e3f (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 7e3fd04eda8706c227b73ddd09e4d104c7c8fb5a
Author: Daniel Baston <dbaston at gmail.com>
Date: Wed Jul 16 17:51:58 2025 -0400
TemplateSTRTree: throw exception on invalid node capacity (#1288)
Resolves https://github.com/libgeos/geos/issues/1287
diff --git a/include/geos/index/strtree/TemplateSTRtree.h b/include/geos/index/strtree/TemplateSTRtree.h
index baae429d0..381aeeea1 100644
--- a/include/geos/index/strtree/TemplateSTRtree.h
+++ b/include/geos/index/strtree/TemplateSTRtree.h
@@ -131,7 +131,9 @@ public:
root(nullptr),
nodeCapacity(p_nodeCapacity),
numItems(0)
- {}
+ {
+ validateConstruction();
+ }
/**
* Constructs a tree with the given maximum number of child nodes that
@@ -141,9 +143,11 @@ public:
TemplateSTRtreeImpl(size_t p_nodeCapacity, size_t itemCapacity) :
root(nullptr),
nodeCapacity(p_nodeCapacity),
- numItems(0) {
+ numItems(0)
+ {
auto finalSize = treeSize(itemCapacity);
nodes.reserve(finalSize);
+ validateConstruction();
}
/**
@@ -678,6 +682,12 @@ protected:
static size_t sliceCapacity(size_t numNodes, size_t numSlices) {
return static_cast<size_t>(std::ceil(static_cast<double>(numNodes) / static_cast<double>(numSlices)));
}
+
+ void validateConstruction() const {
+ if (nodeCapacity < 2) {
+ throw util::IllegalArgumentException("STRTree node capacity must be >= 2");
+ }
+ }
};
struct EnvelopeTraits {
diff --git a/tests/unit/capi/GEOSSTRtreeTest.cpp b/tests/unit/capi/GEOSSTRtreeTest.cpp
index ab3697fab..ad210d464 100644
--- a/tests/unit/capi/GEOSSTRtreeTest.cpp
+++ b/tests/unit/capi/GEOSSTRtreeTest.cpp
@@ -505,6 +505,17 @@ void object::test<14>()
GEOSSTRtree_destroy(tree);
}
+template<>
+template<>
+void object::test<15>()
+{
+ set_test_name("node capacity too small");
+
+ GEOSSTRtree* tree = GEOSSTRtree_create(1);
+ ensure(tree == nullptr);
+}
+
+
} // namespace tut
-----------------------------------------------------------------------
Summary of changes:
include/geos/index/strtree/TemplateSTRtree.h | 14 ++++++++++++--
tests/unit/capi/GEOSSTRtreeTest.cpp | 11 +++++++++++
2 files changed, 23 insertions(+), 2 deletions(-)
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list