[SCM] PostGIS branch master updated. 3.6.0beta1-6-gbac95532a

git at osgeo.org git at osgeo.org
Fri Jul 25 00:49:37 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  bac95532a6e7b25d73243e5a984dc6879fceb771 (commit)
      from  c65dc2b4c09b4864a6181b061f3a0e32a1787973 (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 bac95532a6e7b25d73243e5a984dc6879fceb771
Author: Sandro Santilli <strk at kbt.io>
Date:   Fri Jul 25 09:37:39 2025 +0200

    Fix crash in ST_GetFaceEdges with corrupted topology
    
    References #5951 in master branch (3.6.0dev)

diff --git a/liblwgeom/topo/lwgeom_topo.c b/liblwgeom/topo/lwgeom_topo.c
index 78b7b6dff..4042ee737 100644
--- a/liblwgeom/topo/lwgeom_topo.c
+++ b/liblwgeom/topo/lwgeom_topo.c
@@ -3124,6 +3124,8 @@ lwt_GetFaceEdges(LWT_TOPOLOGY* topo, LWT_ELEMID face_id, LWT_ELEMID **out )
   {
     /* _lwt_FaceByEdges should have already invoked lwerror in this case */
     _lwt_release_edges(edges, numfaceedges);
+    lwerror("Corrupted topology: unable to build geometry of face %"
+      LWTFMT_ELEMID " from its %llu edges", face_id, numfaceedges);
     return -1;
   }
 
diff --git a/topology/postgis_topology.c b/topology/postgis_topology.c
index 75e3961a9..0473bbdd5 100644
--- a/topology/postgis_topology.c
+++ b/topology/postgis_topology.c
@@ -4235,6 +4235,10 @@ Datum ST_GetFaceEdges(PG_FUNCTION_ARGS)
 
   /* get state */
   state = funcctx->user_fctx;
+  if ( ! state )
+  {
+    SRF_RETURN_DONE(funcctx);
+  }
 
   if ( state->curr == state->nelems )
   {
diff --git a/topology/test/regress/st_getfaceedges.sql b/topology/test/regress/st_getfaceedges.sql
index 6ff65b468..356ba1faf 100644
--- a/topology/test/regress/st_getfaceedges.sql
+++ b/topology/test/regress/st_getfaceedges.sql
@@ -41,4 +41,15 @@ SELECT '#3265.3', 'E'||topology.TopoGeo_addLinestring('tt',
 SELECT '#3265.4', 0, ST_GetFaceEdges('tt', 0);
 SELECT '#3265.5', 1, ST_GetFaceEdges('tt', 1);
 SELECT '#3265.6', 2, ST_GetFaceEdges('tt', 2);
-SELECT topology.DropTopology('tt');
+SELECT NULL FROM topology.DropTopology('tt');
+
+-- See https://trac.osgeo.org/postgis/ticket/5951
+SELECT NULL FROM topology.CreateTopology('t5951');
+SELECT NULL FROM topology.TopoGeo_addLinestring('t5951', 'LINESTRING(0 0, 10 0)');
+SELECT NULL FROM topology.TopoGeo_addLinestring('t5951', 'LINESTRING(0 0, 5 5)');
+SELECT NULL FROM topology.TopoGeo_addLinestring('t5951', 'LINESTRING(5 5, 10 0)');
+SELECT NULL FROM topology.TopoGeo_addLinestring('t5951', 'LINESTRING(5 5, 10 5)');
+SELECT NULL FROM topology.TopoGeo_addLinestring('t5951', 'LINESTRING(10 0, 10 5)');
+UPDATE t5951.edge_data SET left_face = 0, right_face = 0 WHERE edge_id = 3;
+SELECT '#5951.1', topology.ST_GetFaceEdges('t5951', face_id) FROM t5951.face WHERE face_id > 0;
+SELECT NULL FROM topology.DropTopology('t5951');

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

Summary of changes:
 liblwgeom/topo/lwgeom_topo.c              |  2 ++
 topology/postgis_topology.c               |  4 ++++
 topology/test/regress/st_getfaceedges.sql | 13 ++++++++++++-
 3 files changed, 18 insertions(+), 1 deletion(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list