[postgis-tickets] [SCM] PostGIS branch stable-3.2 updated. 3.2.1-14-gff3d4b65b

git at osgeo.org git at osgeo.org
Tue May 17 13:28:12 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-3.2 has been updated
       via  ff3d4b65b49481505b341b0250e3d6811d0e1ebc (commit)
      from  26c6f24d9a362cca5dd5f257598112eb1aa8df20 (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 ff3d4b65b49481505b341b0250e3d6811d0e1ebc
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 3.2 branch (3.2.2dev)
    Includes unit and regress test

diff --git a/NEWS b/NEWS
index fd39ee799..8a0684710 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@ PostGIS 3.2.2dev
 2022/MM/DD
 
 * Bug Fixes *
+  - #5152, Fix infinite loop with ST_Split (Sandro Santilli)
   - #5124, GRANT USAGE on topology schema to PUBLIC (Sandro Santilli)
   - #5120, Fix not-null result from ST_EstimatedExtent against
            truncated tables with spatial index (Sandro Santilli)
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:
 NEWS                          |  1 +
 liblwgeom/cunit/cu_split.c    | 14 +++++++++++++-
 liblwgeom/lwgeom_geos_split.c |  1 +
 regress/core/split.sql        |  5 +++++
 regress/core/split_expected   |  1 +
 5 files changed, 21 insertions(+), 1 deletion(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list