[geos-commits] [SCM] GEOS branch 3.7 updated. 2f12a8026afb67431a3d2dc22f34630911b4e226

git at osgeo.org git at osgeo.org
Sun Sep 23 18:25:25 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, 3.7 has been updated
       via  2f12a8026afb67431a3d2dc22f34630911b4e226 (commit)
      from  3afc83d36f6d60da747b475d3223d8268f53e3f1 (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 2f12a8026afb67431a3d2dc22f34630911b4e226
Author: Sergey Fedoseev <fedoseev.sergey at gmail.com>
Date:   Fri Sep 21 01:34:07 2018 +0500

    Fix #926: Fixed crash in GEOSInterpolate() when used with empty LineString.

diff --git a/NEWS b/NEWS
index f4519c7..1e9973e 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,8 @@ Changes in 3.7.1
 - Bug fixes / improvements
   - Fix crash in GEOSCoordSeq_isCCW with empty coordseq
     (#927, Sergey Fedoseev)
+  - Fix crash in GEOSInterpolate with empty LineString
+    (#926, Sergey Fedoseev)
 
 
 3.7.0 changes
diff --git a/src/linearref/LinearLocation.cpp b/src/linearref/LinearLocation.cpp
index fdcebb2..07c1d01 100644
--- a/src/linearref/LinearLocation.cpp
+++ b/src/linearref/LinearLocation.cpp
@@ -194,6 +194,9 @@ LinearLocation::getCoordinate(const Geometry* linearGeom) const
 	if ( ! lineComp ) {
 		throw util::IllegalArgumentException("LinearLocation::getCoordinate only works with LineString geometries");
 	}
+	if (linearGeom->isEmpty()) {
+		return Coordinate::getNull();
+	}
 	Coordinate p0 = lineComp->getCoordinateN(segmentIndex);
 	if (segmentIndex >= lineComp->getNumPoints() - 1)
 		return p0;
diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am
index 8f02cc4..3c84675 100644
--- a/tests/unit/Makefile.am
+++ b/tests/unit/Makefile.am
@@ -168,7 +168,8 @@ geos_unit_SOURCES = \
 	capi/GEOSReverseTest.cpp \
 	capi/GEOSUnaryUnionTest.cpp \
 	capi/GEOSisValidDetailTest.cpp \
-	capi/GEOSisClosedTest.cpp
+	capi/GEOSisClosedTest.cpp \
+	capi/GEOSInterpolateTest.cpp
 
 noinst_HEADERS = \
 	utility.h
diff --git a/tests/unit/capi/GEOSInterpolateTest.cpp b/tests/unit/capi/GEOSInterpolateTest.cpp
new file mode 100644
index 0000000..b5cacc2
--- /dev/null
+++ b/tests/unit/capi/GEOSInterpolateTest.cpp
@@ -0,0 +1,68 @@
+// Test Suite for C-API LineString interpolate functions
+
+#include <tut/tut.hpp>
+// geos
+#include <geos_c.h>
+// std
+#include <cstdarg>
+#include <cstdio>
+#include <cstdlib>
+#include <cmath>
+
+namespace tut
+{
+    //
+    // Test Group
+    //
+
+    // Common data used in test cases.
+    struct test_capiinterpolate_data
+    {
+        GEOSGeometry* geom1_;
+
+        static void notice(const char *fmt, ...)
+        {
+            std::fprintf( stdout, "NOTICE: ");
+
+            va_list ap;
+            va_start(ap, fmt);
+            std::vfprintf(stdout, fmt, ap);
+            va_end(ap);
+
+            std::fprintf(stdout, "\n");
+        }
+
+        test_capiinterpolate_data()
+            : geom1_(nullptr)
+        {
+            initGEOS(notice, notice);
+        }
+
+        ~test_capiinterpolate_data()
+        {
+            GEOSGeom_destroy(geom1_);
+            geom1_ = nullptr;
+            finishGEOS();
+        }
+
+    };
+
+    typedef test_group<test_capiinterpolate_data> group;
+    typedef group::object object;
+
+    group test_capiinterpolate_group("capi::GEOSInterpolate");
+
+    //
+    // Test Cases
+    //
+
+    template<>
+    template<>
+    void object::test<1>()
+    {
+        geom1_ = GEOSGeomFromWKT("LINESTRING EMPTY");
+        GEOSGeometry *geom2 = GEOSInterpolate(geom1_, 1);
+        ensure_equals(GEOSisEmpty(geom2), 1);
+        GEOSGeom_destroy(geom2);
+    }
+} // namespace tut
diff --git a/tests/unit/linearref/LengthIndexedLineTest.cpp b/tests/unit/linearref/LengthIndexedLineTest.cpp
index b9aebb6..23c5e3a 100644
--- a/tests/unit/linearref/LengthIndexedLineTest.cpp
+++ b/tests/unit/linearref/LengthIndexedLineTest.cpp
@@ -470,5 +470,15 @@ void object::test<28>()
 }
 #endif
 
+template<>
+template<>
+void object::test<29>()
+{
+    GeomPtr linearGeom(reader.read("LINESTRING EMPTY"));
+    LengthIndexedLine indexedLine(linearGeom.get());
+    Coordinate pt = indexedLine.extractPoint(100);
+    ensure(pt.isNull());
+}
+
 } // namespace tut
 

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

Summary of changes:
 NEWS                                               |  2 ++
 src/linearref/LinearLocation.cpp                   |  3 ++
 tests/unit/Makefile.am                             |  3 +-
 ...EOSSimplifyTest.cpp => GEOSInterpolateTest.cpp} | 34 ++++++++--------------
 tests/unit/linearref/LengthIndexedLineTest.cpp     | 10 +++++++
 5 files changed, 29 insertions(+), 23 deletions(-)
 copy tests/unit/capi/{GEOSSimplifyTest.cpp => GEOSInterpolateTest.cpp} (56%)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list