[SCM] PostGIS branch stable-3.5 updated. 3.5.3-5-g21bde1da7
git at osgeo.org
git at osgeo.org
Thu May 29 01:10:58 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 21bde1da74c410bd06bfc3e55b826a3f4cb6142a (commit)
via 6c217cdc378c2edc2a355dd46f7fa7d3a53ea26a (commit)
from cffcdca91556caf2cf265fbc908254e23ab29021 (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 21bde1da74c410bd06bfc3e55b826a3f4cb6142a
Author: Sandro Santilli <strk at kbt.io>
Date: Thu May 29 10:03:10 2025 +0200
Fix crash in TopoGeo_AddPolygon with EMPTY input
References #5907 in 3.5 branch (3.5.4dev)
diff --git a/NEWS b/NEWS
index 66e854db5..77ffd44f3 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ PostgreSQL 12-18 required. GEOS 3.8+ required. Proj 6.1+ required.
* Bug fixes *
- #5908, [topology] Fix crash in GetFaceContainingPoint (Sandro Santilli)
+- #5907, [topology] Fix crash in TopoGeo_AddPolygon with EMPTY input (Sandro Santilli)
PostGIS 3.5.3
diff --git a/liblwgeom/topo/lwgeom_topo.c b/liblwgeom/topo/lwgeom_topo.c
index 4643642bb..ef244e628 100644
--- a/liblwgeom/topo/lwgeom_topo.c
+++ b/liblwgeom/topo/lwgeom_topo.c
@@ -7564,6 +7564,13 @@ lwt_AddPolygon(LWT_TOPOLOGY* topo, LWPOLY* poly, double tol, int* nfaces)
const GEOSPreparedGeometry *ppoly;
GEOSGeometry *polyg;
+ /* Nothing to add, in an empty polygon */
+ if ( lwpoly_is_empty(poly) )
+ {
+ *nfaces = 0;
+ return NULL;
+ }
+
/* Get tolerance, if 0 was given */
if ( ! tol ) tol = _LWT_MINTOLERANCE( topo, (LWGEOM*)poly );
LWDEBUGF(1, "Working tolerance:%.15g", tol);
diff --git a/topology/test/regress/topogeo_addpolygon.sql b/topology/test/regress/topogeo_addpolygon.sql
index f7ace00a1..44b788a42 100644
--- a/topology/test/regress/topogeo_addpolygon.sql
+++ b/topology/test/regress/topogeo_addpolygon.sql
@@ -19,7 +19,7 @@ DECLARE
sql text;
BEGIN
-- Check effect on nodes
- sql := 'SELECT $1 || ''|N|'' ' || CASE WHEN add_id THEN ' || n.node_id || ''|'' ' ELSE '' END || ' ||
+ sql := 'SELECT $1 || ''|N|'' ' || CASE WHEN add_id THEN ' || n.node_id || ''|'' ' ELSE '' END || ' ||
COALESCE(n.containing_face::text,'''') || ''|'' ||
ST_AsText(ST_SnapToGrid(n.geom, 0.2))::text as xx
FROM city_data.node n WHERE n.node_id > (
@@ -35,7 +35,7 @@ BEGIN
-- Check effect on edges (there should be one split)
sql := 'WITH node_limits AS ( SELECT max FROM city_data.limits WHERE what = ''node''::text ),
edge_limits AS ( SELECT max FROM city_data.limits WHERE what = ''edge''::text )
- SELECT $1 || ''|E|'' ' || CASE WHEN add_id THEN ' || e.edge_id || ''|sn'' || e.start_node || ''|en'' || e.end_node::text ' ELSE '' END || ' AS xx ' ||
+ SELECT $1 || ''|E|'' ' || CASE WHEN add_id THEN ' || e.edge_id || ''|sn'' || e.start_node || ''|en'' || e.end_node::text ' ELSE '' END || ' AS xx ' ||
' FROM city_data.edge e, node_limits nl, edge_limits el
WHERE e.start_node > nl.max
OR e.end_node > nl.max
@@ -72,6 +72,7 @@ $$ LANGUAGE 'plpgsql';
SELECT 'invalid', TopoGeo_addPolygon('city_data', 'MULTILINESTRING((36 26, 38 30))');
SELECT 'invalid', TopoGeo_addPolygon('city_data', 'POINT(36 26)');
SELECT 'invalid', TopoGeo_addPolygon('invalid', 'POLYGON((36 26, 40 24, 40 30, 36 26))');
+SELECT 'empty', TopoGeo_addPolygon('city_data', 'POLYGON EMPTY');
-- Isolated face in universal face
SELECT 'iso_uni', TopoGeo_addPolygon('city_data', 'POLYGON((36 26, 38 30, 43 26, 36 26))');
@@ -145,11 +146,11 @@ SELECT 't1946.1', topology.topogeo_AddPolygon('bug1946',
76.68727 30.74249,76.67933 30.75,
76.69223 30.74157,76.68728 30.74248))'
::geometry); **/
-SELECT 't1946.2', COUNT(*)
+SELECT 't1946.2', COUNT(*)
FROM topology.topogeo_AddPolygon('bug1946',
'POLYGON((76.68728 30.74248,76.68727 30.74248,
76.68727 30.74249,76.67933 30.75,
76.69223 30.74157,76.68728 30.74248))'
-::geometry);
+::geometry);
SELECT 't1946.end', topology.DropTopology('bug1946');
commit 6c217cdc378c2edc2a355dd46f7fa7d3a53ea26a
Author: Sandro Santilli <strk at kbt.io>
Date: Thu May 29 09:39:47 2025 +0200
Make GetFaceContainingPoint survive to NULL arguments and EMPTY points
References #5908 in 3.5 branch (3.5.4dev)
diff --git a/NEWS b/NEWS
index d1d0ac7d4..66e854db5 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,10 @@ xxxx/xx/xx
To take advantage of all postgis_sfcgal extension features SFCGAL 1.5+ is needed.
PostgreSQL 12-18 required. GEOS 3.8+ required. Proj 6.1+ required.
+* Bug fixes *
+
+- #5908, [topology] Fix crash in GetFaceContainingPoint (Sandro Santilli)
+
PostGIS 3.5.3
2025/05/17
diff --git a/topology/postgis_topology.c b/topology/postgis_topology.c
index 7b497bc8b..ae7521a29 100644
--- a/topology/postgis_topology.c
+++ b/topology/postgis_topology.c
@@ -5518,7 +5518,7 @@ Datum GetRingEdges(PG_FUNCTION_ARGS)
SRF_RETURN_NEXT(funcctx, result);
}
-/* GetFaceContainingPoint(atopology, point) */
+/* GetFaceContainingPoint(atopology, point) */
Datum GetFaceContainingPoint(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(GetFaceContainingPoint);
Datum GetFaceContainingPoint(PG_FUNCTION_ARGS)
@@ -5531,6 +5531,12 @@ Datum GetFaceContainingPoint(PG_FUNCTION_ARGS)
LWPOINT *pt;
LWT_TOPOLOGY *topo;
+ if ( PG_ARGISNULL(0) || PG_ARGISNULL(1) )
+ {
+ /* should only happen when the SQL function is not declared STRICT */
+ PG_RETURN_NULL();
+ }
+
toponame_text = PG_GETARG_TEXT_P(0);
toponame = text_to_cstring(toponame_text);
PG_FREE_IF_COPY(toponame_text, 0);
@@ -5546,6 +5552,14 @@ Datum GetFaceContainingPoint(PG_FUNCTION_ARGS)
PG_RETURN_NULL();
}
+ if ( lwpoint_is_empty(pt) )
+ {
+ lwgeom_free(lwgeom);
+ PG_FREE_IF_COPY(geom, 1);
+ lwpgerror("Second argument needs be a non-empty point");
+ PG_RETURN_NULL();
+ }
+
if ( SPI_OK_CONNECT != SPI_connect() )
{
lwpgerror("Could not connect to SPI");
diff --git a/topology/sql/query/GetFaceContainingPoint.sql.in b/topology/sql/query/GetFaceContainingPoint.sql.in
index bd48bd2c8..9f84c4da5 100644
--- a/topology/sql/query/GetFaceContainingPoint.sql.in
+++ b/topology/sql/query/GetFaceContainingPoint.sql.in
@@ -27,4 +27,4 @@ CREATE OR REPLACE FUNCTION topology.GetFaceContainingPoint(
)
RETURNS INT AS
'MODULE_PATHNAME', 'GetFaceContainingPoint'
-LANGUAGE 'c' STABLE;
+LANGUAGE 'c' STABLE STRICT;
diff --git a/topology/test/regress/getfacecontainingpoint.sql b/topology/test/regress/getfacecontainingpoint.sql
index 16e80ad1a..e1a11b90c 100644
--- a/topology/test/regress/getfacecontainingpoint.sql
+++ b/topology/test/regress/getfacecontainingpoint.sql
@@ -54,7 +54,11 @@ SELECT NULL FROM topology.TopoGeo_addLineString('city_data', 'LINESTRING(43.58 8
SELECT NULL FROM topology.TopoGeo_addLineString('city_data', 'LINESTRING(45 8, 44 9)');
SELECT NULL FROM topology.TopoGeo_addLineString('city_data', 'LINESTRING(45 8, 43.58 8.2)');
-
+-- Corner case calls
+SELECT 'null1' FROM topology.GetFaceContainingPoint(null, 'POINT(0 0)');
+SELECT 'null2' FROM topology.GetFaceContainingPoint('city_data', null);
+SELECT 'null3' FROM topology.GetFaceContainingPoint(null, null);
+SELECT 'empty' FROM topology.GetFaceContainingPoint('city_data', 'POINT EMPTY');
-- Get face containing the "point on surface" of each face's geometry
diff --git a/topology/test/regress/getfacecontainingpoint_expected b/topology/test/regress/getfacecontainingpoint_expected
index 9df926e16..fe96a3245 100644
--- a/topology/test/regress/getfacecontainingpoint_expected
+++ b/topology/test/regress/getfacecontainingpoint_expected
@@ -1,3 +1,7 @@
+null1
+null2
+null3
+ERROR: Second argument needs be a non-empty point
pos|1|1
pos|2|2
pos|3|3
-----------------------------------------------------------------------
Summary of changes:
NEWS | 5 +++++
liblwgeom/topo/lwgeom_topo.c | 7 +++++++
topology/postgis_topology.c | 16 +++++++++++++++-
topology/sql/query/GetFaceContainingPoint.sql.in | 2 +-
topology/test/regress/getfacecontainingpoint.sql | 6 +++++-
topology/test/regress/getfacecontainingpoint_expected | 4 ++++
topology/test/regress/topogeo_addpolygon.sql | 9 +++++----
7 files changed, 42 insertions(+), 7 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list