[SCM] PostGIS branch master updated. 3.5.0-351-g7de380c15

git at osgeo.org git at osgeo.org
Thu May 29 01:10:45 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, master has been updated
       via  7de380c157eee47244d7adfc112c3b980b405007 (commit)
      from  1f7efb045c38896a5d8f0393fa5dee335941f281 (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 7de380c157eee47244d7adfc112c3b980b405007
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 master branch (3.6.0dev)

diff --git a/liblwgeom/topo/lwgeom_topo.c b/liblwgeom/topo/lwgeom_topo.c
index 027392f6e..6d938d5b6 100644
--- a/liblwgeom/topo/lwgeom_topo.c
+++ b/liblwgeom/topo/lwgeom_topo.c
@@ -7547,6 +7547,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');

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

Summary of changes:
 liblwgeom/topo/lwgeom_topo.c                 | 7 +++++++
 topology/test/regress/topogeo_addpolygon.sql | 9 +++++----
 2 files changed, 12 insertions(+), 4 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list