[SCM] PostGIS branch stable-3.3 updated. 3.3.7-32-g3d38a0063

git at osgeo.org git at osgeo.org
Thu May 29 00:50:50 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.3 has been updated
       via  3d38a0063823215b0e9821848f90834326361c3f (commit)
      from  a52285d20a14050a209c3a8fd7c9e66e5983ec8a (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 3d38a0063823215b0e9821848f90834326361c3f
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.3 branch (3.3.9dev)

diff --git a/NEWS b/NEWS
index b004007b3..c46705a13 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-PostGIS 3.3.9
+PostGIS 3.3.9dev
 xxxx-xx-xx
 
 PostgreSQL 11-17 required. GEOS 3.6+ required but GEOS 3.11+ to take advantage of all features.
@@ -6,6 +6,7 @@ Proj 4.9+ required.
 
 * Bug Fixes and Enhancements *
 
+ - #5908, [topology] Fix crash in GetFaceContainingPoint (Sandro Santilli)
  - #5876, Fix ST_AddPoint with empty point argument (Paul Ramsey)
  - #5829, geometry_columns with non-standard constraints (Paul Ramsey)
  - #5818, GT-244 Fix CG_IsSolid function (Loïc Bartoletti)
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                                                  |  3 ++-
 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, 27 insertions(+), 4 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list