[SCM] PostGIS branch stable-3.5 updated. 3.5.2-14-g9024a3732

git at osgeo.org git at osgeo.org
Mon Apr 7 12:33:20 PDT 2025


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.5 has been updated
       via  9024a3732d942893e92f85e4986f05da8773fda5 (commit)
      from  7c417a1773631793808e9781d6b99817552b9edd (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 9024a3732d942893e92f85e4986f05da8773fda5
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Mon Apr 7 12:32:41 2025 -0700

    Fix ST_AddPoint with empty point argument
    References #5876

diff --git a/NEWS b/NEWS
index d6cb1b956..a8c35ebe8 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,7 @@ PostgreSQL 12-18 required. GEOS 3.8+ required. Proj 6.1+ required.
 - #5855, Fix index binding in ST_DFullyWithin (Paul Ramsey)
 - #5819, Support longer names in estimated extent (Paul Ramsey)
 - Fix misassignment of result in _lwt_HealEdges (Maxim Korotkov)
+- #5876, ST_AddPoint with empty argument adds garbage (Paul Ramsey)
 
 
 
diff --git a/liblwgeom/lwgeom_api.c b/liblwgeom/lwgeom_api.c
index b51a65d75..c75bbb6ca 100644
--- a/liblwgeom/lwgeom_api.c
+++ b/liblwgeom/lwgeom_api.c
@@ -107,7 +107,8 @@ POINT4D
 getPoint4d(const POINTARRAY *pa, uint32_t n)
 {
 	POINT4D result;
-	getPoint4d_p(pa, n, &result);
+	if (getPoint4d_p(pa, n, &result) == 0)
+		lwerror("%s [%d] error returned by getPoint4d_p", __FILE__, __LINE__);
 	return result;
 }
 
@@ -134,7 +135,7 @@ getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *op)
 
 	if ( n>=pa->npoints )
 	{
-		LWDEBUGF(2, "%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->npoints);
+		lwerror("%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->npoints);
 		return 0;
 	}
 
diff --git a/postgis/lwgeom_functions_basic.c b/postgis/lwgeom_functions_basic.c
index 1f9348c1b..974fad631 100644
--- a/postgis/lwgeom_functions_basic.c
+++ b/postgis/lwgeom_functions_basic.c
@@ -2294,6 +2294,11 @@ Datum LWGEOM_addpoint(PG_FUNCTION_ARGS)
 		PG_RETURN_NULL();
 	}
 
+	if (gserialized_is_empty(pglwg2))
+	{
+		PG_RETURN_POINTER(pglwg1);
+	}
+
 	line = lwgeom_as_lwline(lwgeom_from_gserialized(pglwg1));
 
 	if (PG_NARGS() <= 2)
diff --git a/regress/core/tickets.sql b/regress/core/tickets.sql
index 40df77830..cf519dff0 100644
--- a/regress/core/tickets.sql
+++ b/regress/core/tickets.sql
@@ -1557,3 +1557,7 @@ SELECT '#5677',
 SELECT '#5686', ST_NumInteriorRings('TRIANGLE (( -71.0821 42.3036, -71.0821 42.3936, -71.0901 42.3036, -71.0821 42.3036))'::geometry);
 
 SELECT '#5747', ST_Length('MULTISURFACE (((0 0, 1 0, 1 1, 0 1, 0 0)), CURVEPOLYGON (CIRCULARSTRING (10 10, 11 11, 12 10, 11 9, 10 10)))'::geometry);
+
+SELECT '#5876', ST_AsText(ST_AddPoint(
+		'LINESTRING (1 1, 2 2)'::geometry,
+		'POINT EMPTY'::geometry), 2);
diff --git a/regress/core/tickets_expected b/regress/core/tickets_expected
index f2ebc6e25..35b8ce430 100644
--- a/regress/core/tickets_expected
+++ b/regress/core/tickets_expected
@@ -481,3 +481,4 @@ ERROR:  Geometry contains invalid coordinates
 #5677|POLYGON((0 0,0 10,20 22,20 30,30 30,30 20,22 20,10 0,0 0))
 #5686|0
 #5747|0
+#5876|LINESTRING(1 1,2 2)

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

Summary of changes:
 NEWS                             | 1 +
 liblwgeom/lwgeom_api.c           | 5 +++--
 postgis/lwgeom_functions_basic.c | 5 +++++
 regress/core/tickets.sql         | 4 ++++
 regress/core/tickets_expected    | 1 +
 5 files changed, 14 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list