[postgis-tickets] [SCM] PostGIS branch master updated. 3.2.0-862-g5cff5f777

git at osgeo.org git at osgeo.org
Tue May 17 08:09:31 PDT 2022


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 "PostGIS".

The branch, master has been updated
       via  5cff5f7777e1562129799f4b479bbfdb218baa28 (commit)
      from  3389bf538ae1e7b5c8258c9cc1af49752b3bd180 (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 5cff5f7777e1562129799f4b479bbfdb218baa28
Author: Sandro Santilli <strk at kbt.io>
Date:   Tue May 17 12:19:12 2022 +0200

    Fix infinite loop in lwline_split_by_point_to
    
    References #5152 in master branch
    Includes unit and regress test

diff --git a/liblwgeom/cunit/cu_split.c b/liblwgeom/cunit/cu_split.c
index b7bcb1e5d..edbf00aa4 100644
--- a/liblwgeom/cunit/cu_split.c
+++ b/liblwgeom/cunit/cu_split.c
@@ -74,8 +74,20 @@ static void test_lwline_split_by_point_to(void)
 	CU_ASSERT_EQUAL(coll->ngeoms, 4);
 	lwpoint_free(point);
 
-	lwcollection_free((LWCOLLECTION*)coll);
 	lwline_free(line);
+
+	line = lwgeom_as_lwline(lwgeom_from_wkt("LINESTRING EMPTY",
+		LW_PARSER_CHECK_NONE));
+	CU_ASSERT(line != NULL);
+	point = lwgeom_as_lwpoint(lwgeom_from_wkt(
+		"POINT(0 0)", LW_PARSER_CHECK_NONE));
+	CU_ASSERT(point != NULL);
+	ret = lwline_split_by_point_to(line, point, coll);
+	CU_ASSERT_EQUAL(ret, 0); /* the point is not on the line */
+	lwpoint_free(point);
+	lwline_free(line);
+
+	lwcollection_free((LWCOLLECTION*)coll);
 }
 
 static void test_lwgeom_split(void)
diff --git a/liblwgeom/lwgeom_geos_split.c b/liblwgeom/lwgeom_geos_split.c
index efc9348d1..83038a485 100644
--- a/liblwgeom/lwgeom_geos_split.c
+++ b/liblwgeom/lwgeom_geos_split.c
@@ -233,6 +233,7 @@ lwline_split_by_point_to(const LWLINE* lwline_in, const LWPOINT* blade_in,
 	getPoint4d_p(blade_in->point, 0, &pt);
 
 	/* Find closest segment */
+	if ( ipa->npoints < 1 ) return 0; /* empty input line */
 	getPoint4d_p(ipa, 0, &p1);
 	nsegs = ipa->npoints - 1;
 	for ( i = 0; i < nsegs; i++ )
diff --git a/regress/core/split.sql b/regress/core/split.sql
index 7a2eaf9f0..2374026cc 100644
--- a/regress/core/split.sql
+++ b/regress/core/split.sql
@@ -102,4 +102,9 @@ select '86', ST_AsEWKT(ST_Split(
   'SRID=3;MULTIPOINT(2 6,5 0,5 20,2 20,8 20,8 0,5 -2,0 0, 5 -5, 10 20)'
 ));
 
+-- Split empty line by point
+-- See http://trac.osgeo.org/postgis/ticket/5152
+select '87', ST_AsEWKT(ST_Split('SRID=4326;LINESTRING EMPTY', 'SRID=4326;POINT(0 1)'));
+
+
 -- TODO: split line by collapsed line
diff --git a/regress/core/split_expected b/regress/core/split_expected
index dab2da4cb..b8a5287e9 100644
--- a/regress/core/split_expected
+++ b/regress/core/split_expected
@@ -28,3 +28,4 @@ ERROR:  Splitter line has linear intersection with input
 84|SRID=3;GEOMETRYCOLLECTION(LINESTRING(1 -1,1 0),LINESTRING(1 0,1 1))
 85|SRID=3;GEOMETRYCOLLECTION(LINESTRING(1 -2,1 -1),LINESTRING(1 -1,1 1,3 1),LINESTRING(3 1,4 1))
 86|SRID=3;GEOMETRYCOLLECTION(LINESTRING(8 0,10 0),LINESTRING(0 0,5 0),LINESTRING(5 0,8 0),LINESTRING(5 0,5 5),LINESTRING(5 -2,5 0),LINESTRING(5 -5,5 -2),LINESTRING(8 20,10 20),LINESTRING(2 20,5 20),LINESTRING(0 20,2 20),LINESTRING(5 20,8 20))
+87|SRID=4326;GEOMETRYCOLLECTION(LINESTRING EMPTY)

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

Summary of changes:
 liblwgeom/cunit/cu_split.c    | 14 +++++++++++++-
 liblwgeom/lwgeom_geos_split.c |  1 +
 regress/core/split.sql        |  5 +++++
 regress/core/split_expected   |  1 +
 4 files changed, 20 insertions(+), 1 deletion(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list