[SCM] PostGIS branch stable-3.4 updated. 3.4.4-22-g6fe240389
git at osgeo.org
git at osgeo.org
Thu May 29 00:49:28 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.4 has been updated
via 6fe2403898f71c5a9a0a6de66f73c1faa7dd0ea7 (commit)
from 8aac1dbcbbec0ca75a4ff2ba4178146b812ce957 (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 6fe2403898f71c5a9a0a6de66f73c1faa7dd0ea7
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.4 branch (3.4.5dev)
diff --git a/NEWS b/NEWS
index 9de7c7602..397ef6321 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ Proj 6.1+ required.
* Bug Fixes *
+ - #5908, [topology] Fix crash in GetFaceContainingPoint (Sandro Santilli)
- Do not complain about illegal option when calling shp2pgsql -?
- #5564, BRIN crash fix and support for parallel in PG17+
(Paul Ramsey, Regina Obe)
diff --git a/topology/postgis_topology.c b/topology/postgis_topology.c
index 8e3900b00..ea5ae9ddd 100644
--- a/topology/postgis_topology.c
+++ b/topology/postgis_topology.c
@@ -5439,7 +5439,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)
@@ -5452,6 +5452,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);
@@ -5467,6 +5473,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 | 1 +
topology/postgis_topology.c | 16 +++++++++++++++-
topology/sql/query/GetFaceContainingPoint.sql.in | 2 +-
topology/test/regress/getfacecontainingpoint.sql | 6 +++++-
topology/test/regress/getfacecontainingpoint_expected | 4 ++++
5 files changed, 26 insertions(+), 3 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list