[postgis-tickets] [SCM] PostGIS branch stable-2.5 updated. 2.5.6-2-g260e4b6e7

git at osgeo.org git at osgeo.org
Tue May 17 13:31:47 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, stable-2.5 has been updated
       via  260e4b6e7a105033962b9b460e7b47ed9bde16ba (commit)
      from  2288f7310a845d97eaa42885694ff87941b28976 (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 260e4b6e7a105033962b9b460e7b47ed9bde16ba
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
    
    Closes #5152 in 2.5 branch (2.5.7dev)
    Includes unit and regress test

diff --git a/NEWS b/NEWS
index 0be720bee..1ab0f634f 100644
--- a/NEWS
+++ b/NEWS
@@ -1,7 +1,10 @@
-PostGIS 2.5.7
-xxxx/xx/xx
+PostGIS 2.5.7dev
+2022/xx/xx
+
  * Bug fixes *
 
+  - #5152, Fix infinite loop with ST_Split (Sandro Santilli)
+
 PostGIS 2.5.6
 2022/04/20
 
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 459fec9f9..5d5593d86 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/split.sql b/regress/split.sql
index e8554453d..a8d2a8ef7 100644
--- a/regress/split.sql
+++ b/regress/split.sql
@@ -102,4 +102,8 @@ 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/split_expected b/regress/split_expected
index 64735cf0c..6181214b9 100644
--- a/regress/split_expected
+++ b/regress/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:
 NEWS                          |  7 +++++--
 liblwgeom/cunit/cu_split.c    | 14 +++++++++++++-
 liblwgeom/lwgeom_geos_split.c |  1 +
 regress/split.sql             |  4 ++++
 regress/split_expected        |  1 +
 5 files changed, 24 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list