[SCM] PostGIS branch stable-3.2 updated. 3.2.7-34-g9f73023a1

git at osgeo.org git at osgeo.org
Thu May 29 00:50:59 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.2 has been updated
       via  9f73023a13df8f7fa84ad9774db0967a6f134be5 (commit)
      from  4b90658bfa58ab481c102811ca87066f8bf95f9e (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 9f73023a13df8f7fa84ad9774db0967a6f134be5
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
    
    Closes #5908 in 3.2 branch (3.2.9dev)

diff --git a/NEWS b/NEWS
index dead72389..f9b45b536 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-PostGIS 3.2.9
+PostGIS 3.2.9dev
 xxxx/xx/xx
 
 PostgreSQL 9.6-15 required. GEOS 3.6+ required but GEOS 3.9+ to take advantage of all features.
@@ -6,6 +6,7 @@ Proj 4.9+ required.
 
 * Bug Fixes  *
 
+ - #5908, [topology] Fix crash in GetFaceContainingPoint (Sandro Santilli)
  - #5876, Fix ST_AddPoint with empty point argument (Paul Ramsey)
  - #5818, GT-244 Fix CG_IsSolid function (Loïc Bartoletti)
  - #5885, Fix documentation about grid-based overlay operations (Sandro Santilli)
diff --git a/topology/postgis_topology.c b/topology/postgis_topology.c
index 1b1218ffe..aca7a07a4 100644
--- a/topology/postgis_topology.c
+++ b/topology/postgis_topology.c
@@ -5323,7 +5323,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)
@@ -5336,6 +5336,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);
@@ -5351,6 +5357,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 df7a48581..3a0295088 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