[geos-commits] [SCM] GEOS branch master updated. f6a0efd1f243f7edd6dec5e346e57f4f7a1fc17d

git at osgeo.org git at osgeo.org
Mon Nov 19 07:05:26 PST 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  f6a0efd1f243f7edd6dec5e346e57f4f7a1fc17d (commit)
       via  23db5ed049bf5c149c2c048094602908932d9979 (commit)
      from  70a9773c5d61b419e7f6a7cfb87b28c71fc8c13e (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 f6a0efd1f243f7edd6dec5e346e57f4f7a1fc17d
Merge: 70a9773 23db5ed
Author: Daniel Baston <dbaston at gmail.com>
Date:   Mon Nov 19 10:05:08 2018 -0500

    Merge branch 'trac-919'


commit 23db5ed049bf5c149c2c048094602908932d9979
Author: Daniel Baston <dbaston at gmail.com>
Date:   Thu Nov 15 22:05:04 2018 -0500

    Fix memory leak in SIRtree
    
    Resolves #919

diff --git a/include/geos/index/strtree/SIRtree.h b/include/geos/index/strtree/SIRtree.h
index 54f7895..9e9c275 100644
--- a/include/geos/index/strtree/SIRtree.h
+++ b/include/geos/index/strtree/SIRtree.h
@@ -76,6 +76,12 @@ public:
 	 */
 	std::vector<void*>* query(double x) { return query(x,x); }
 
+	/**
+	 * Disable copy construction and assignment. Apparently needed to make this
+	 * class compile under MSVC. (See https://stackoverflow.com/q/29565299)
+	 */
+	 SIRtree(const SIRtree&) = delete;
+	 SIRtree& operator=(const SIRtree&) = delete;
 
 protected:
 
@@ -98,8 +104,8 @@ protected:
 	std::unique_ptr<BoundableList> sortBoundables(const BoundableList* input) override;
 
 private:
-
 	IntersectsOp* intersectsOp;
+	std::vector<std::unique_ptr<Interval>> intervals;
 };
 
 
diff --git a/src/index/strtree/SIRtree.cpp b/src/index/strtree/SIRtree.cpp
index 4c8452f..06343e2 100644
--- a/src/index/strtree/SIRtree.cpp
+++ b/src/index/strtree/SIRtree.cpp
@@ -127,8 +127,10 @@ SIRtree::createNode(int level)
 /**
 * Inserts an item having the given bounds into the tree.
 */
-void SIRtree::insert(double x1, double x2,void* item) {
-	AbstractSTRtree::insert(new Interval(min(x1,x2),max(x1, x2)),item);
+void SIRtree::insert(double x1, double x2, void* item) {
+	std::unique_ptr<Interval> i{new Interval(std::min(x1,x2), std::max(x1, x2))};
+	AbstractSTRtree::insert(i.get(), item);
+	intervals.push_back(std::move(i));
 }
 
 std::unique_ptr<BoundableList>
diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am
index 3c84675..17efa4d 100644
--- a/tests/unit/Makefile.am
+++ b/tests/unit/Makefile.am
@@ -79,6 +79,7 @@ geos_unit_SOURCES = \
 	geom/TriangleTest.cpp \
 	geom/util/GeometryExtracterTest.cpp \
 	index/quadtree/DoubleBitsTest.cpp \
+	index/strtree/SIRtreeTest.cpp \
 	io/ByteOrderValuesTest.cpp \
 	io/WKBReaderTest.cpp \
 	io/WKBWriterTest.cpp \
diff --git a/tests/unit/index/strtree/SIRtreeTest.cpp b/tests/unit/index/strtree/SIRtreeTest.cpp
new file mode 100644
index 0000000..0ae842e
--- /dev/null
+++ b/tests/unit/index/strtree/SIRtreeTest.cpp
@@ -0,0 +1,34 @@
+#include <tut/tut.hpp>
+// geos
+#include <geos/index/strtree/SIRtree.h>
+
+using namespace geos::index::strtree;
+
+namespace tut
+{
+    // dummy data, not used
+    struct test_sirtree_data {};
+
+    using group = test_group<test_sirtree_data>;
+    using object = group::object;
+
+    group test_sirtree_group("geos::index::strtree::SIRtree");
+
+    //
+    // Test Cases
+    //
+
+    // Make sure no memory is leaked.
+    // See https://trac.osgeo.org/geos/ticket/919
+    template<>
+    template<>
+    void object::test<1>()
+    {
+        SIRtree t;
+        double value = 3;
+        t.insert(1, 5, &value);
+    }
+
+
+} // namespace tut
+

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

Summary of changes:
 include/geos/index/strtree/SIRtree.h     |  8 +++++++-
 src/index/strtree/SIRtree.cpp            |  6 ++++--
 tests/unit/Makefile.am                   |  1 +
 tests/unit/index/strtree/SIRtreeTest.cpp | 34 ++++++++++++++++++++++++++++++++
 4 files changed, 46 insertions(+), 3 deletions(-)
 create mode 100644 tests/unit/index/strtree/SIRtreeTest.cpp


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list