[SCM] PostGIS branch master updated. 3.4.0rc1-1088-g1d12c312b

git at osgeo.org git at osgeo.org
Mon Apr 15 02:26:55 PDT 2024


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, master has been updated
       via  1d12c312bdb2b7d900a01d0259b1f1259edf211d (commit)
      from  2e4d963934d03875674d9f1e7c41e45432c3ffae (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 1d12c312bdb2b7d900a01d0259b1f1259edf211d
Author: Sandro Santilli <strk at kbt.io>
Date:   Mon Apr 15 11:26:14 2024 +0200

    Fix crash on NULL geometry input to LoadGeometry
    
    Also short-circuit the EMPTY case
    Includes regress test.
    
    Closes #5712

diff --git a/topology/postgis_topology.c b/topology/postgis_topology.c
index 1ba5dea36..b6c5ea8ac 100644
--- a/topology/postgis_topology.c
+++ b/topology/postgis_topology.c
@@ -5627,12 +5627,17 @@ Datum TopoGeo_LoadGeometry(PG_FUNCTION_ARGS)
   LWGEOM *lwgeom;
   LWT_TOPOLOGY *topo;
 
+  if ( PG_ARGISNULL(0) || PG_ARGISNULL(1) )
+  {
+    lwpgerror("SQL/MM Spatial exception - null argument");
+    PG_RETURN_NULL();
+  }
+
   toponame_text = PG_GETARG_TEXT_P(0);
   toponame = text_to_cstring(toponame_text);
   PG_FREE_IF_COPY(toponame_text, 0);
 
   geom = PG_GETARG_GSERIALIZED_P(1);
-  lwgeom = lwgeom_from_gserialized(geom);
 
   tol = PG_GETARG_FLOAT8(2);
   if ( tol < 0 )
@@ -5657,10 +5662,16 @@ Datum TopoGeo_LoadGeometry(PG_FUNCTION_ARGS)
     PG_RETURN_NULL();
   }
 
-  POSTGIS_DEBUG(1, "Calling lwt_LoadGeometry");
-  lwt_LoadGeometry(topo, lwgeom, tol);
-  POSTGIS_DEBUG(1, "lwt_LoadGeometry returned");
-  lwgeom_free(lwgeom);
+  /* Nothing to do if the input is empty */
+  if (gserialized_is_empty(geom) != LW_TRUE)
+  {
+    lwgeom = lwgeom_from_gserialized(geom);
+    POSTGIS_DEBUG(1, "Calling lwt_LoadGeometry");
+    lwt_LoadGeometry(topo, lwgeom, tol);
+    POSTGIS_DEBUG(1, "lwt_LoadGeometry returned");
+    lwgeom_free(lwgeom);
+  }
+
   PG_FREE_IF_COPY(geom, 1);
   lwt_FreeTopology(topo);
 
diff --git a/topology/test/regress/topogeo_loadgeometry.sql b/topology/test/regress/topogeo_loadgeometry.sql
index dbb3db8d6..ce434305b 100644
--- a/topology/test/regress/topogeo_loadgeometry.sql
+++ b/topology/test/regress/topogeo_loadgeometry.sql
@@ -1,4 +1,8 @@
 SET client_min_messages TO WARNING;
+
+-- Unexisted topology call
+SELECT 'unexistent_topo', topology.TopoGeo_LoadGeometry('t', 'POINT(0 0)'::geometry);
+
 SELECT NULL FROM topology.CreateTopology('t');
 
 CREATE FUNCTION t.print_counts(lbl text) RETURNS TEXT
@@ -11,6 +15,12 @@ AS $$
   );
 $$ LANGUAGE 'sql';
 
+-- Null call
+SELECT 'null', topology.TopoGeo_LoadGeometry('t', NULL::geometry);
+
+-- Empty
+SELECT 'empty', topology.TopoGeo_LoadGeometry('t', 'POINT EMPTY'::geometry);
+
 --
 --
 --            o
diff --git a/topology/test/regress/topogeo_loadgeometry_expected b/topology/test/regress/topogeo_loadgeometry_expected
index 1467fa7f6..2063bf22e 100644
--- a/topology/test/regress/topogeo_loadgeometry_expected
+++ b/topology/test/regress/topogeo_loadgeometry_expected
@@ -1,3 +1,6 @@
+ERROR:  SQL/MM Spatial exception - invalid topology name
+ERROR:  SQL/MM Spatial exception - null argument
+empty|
 point1|1 nodes|0 edges|0 faces
 mpoint1|2 nodes|0 edges|0 faces
 mline1|6 nodes|4 edges|0 faces

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

Summary of changes:
 topology/postgis_topology.c                         | 21 ++++++++++++++++-----
 topology/test/regress/topogeo_loadgeometry.sql      | 10 ++++++++++
 topology/test/regress/topogeo_loadgeometry_expected |  3 +++
 3 files changed, 29 insertions(+), 5 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list