[geos-commits] [SCM] GEOS branch 3.7 updated. 15d9fd34fbe1d5f0f4a8cad085d2954ca0638914

git at osgeo.org git at osgeo.org
Mon Nov 19 07:06:59 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, 3.7 has been updated
       via  15d9fd34fbe1d5f0f4a8cad085d2954ca0638914 (commit)
       via  8f07342e71f9218d2ec2a9463e83b39271a26e17 (commit)
      from  4c2ab3589a50e180075432beee104d7c5c534d9c (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 15d9fd34fbe1d5f0f4a8cad085d2954ca0638914
Author: Daniel Baston <dbaston at gmail.com>
Date:   Mon Nov 19 10:06:47 2018 -0500

    Add NEWS entry for #919

diff --git a/NEWS b/NEWS
index 59bc181..6b19423 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ Changes in 3.7.1
     (#926, Sergey Fedoseev)
   - Fix crash in GEOSUnaryUnion with empty LineString
     (#928, Sergey Fedoseev)
+  - Fix memory leak in SIRtree::insert (#919, Dan Baston)
   - Reduce required autoconf to 2.63
     (#56, John Harvey)
   - Fix incorrect return values on error from GEOSLength

commit 8f07342e71f9218d2ec2a9463e83b39271a26e17
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 b5a2cbd..78be293 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:
 NEWS                                     |  1 +
 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 ++++++++++++++++++++++++++++++++
 5 files changed, 47 insertions(+), 3 deletions(-)
 create mode 100644 tests/unit/index/strtree/SIRtreeTest.cpp


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list