[postgis-tickets] [SCM] PostGIS branch stable-3.2 updated. 3.2.4-3-ge3298c042

git at osgeo.org git at osgeo.org
Mon Jan 30 08:25:46 PST 2023


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  e3298c042adaa081a1a4bc3a66cf46a243e50032 (commit)
      from  e0b335cf374b36dfd17683b845b75de5278f4815 (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 e3298c042adaa081a1a4bc3a66cf46a243e50032
Author: Sandro Santilli <strk at kbt.io>
Date:   Mon Jan 30 14:41:02 2023 +0100

    Fix segfault in _lwt_RemEdge when no edge side-faces are found
    
    Closes #5106 in 3.2 branch (3.2.5dev)
    
    Includes regress tests

diff --git a/NEWS b/NEWS
index 047d9531f..684be58d9 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,5 @@
 PostGIS 3.2.5dev
-xxxx/xx/xx
+2023/MM/DD
 
 This version requires PostgreSQL 9.6-15, GEOS 3.6 or higher, and Proj 4.9+
 Additional features are enabled if you are running GEOS 3.9+
@@ -7,7 +7,8 @@ Additional features are enabled if you are running GEOS 3.9+
 Proj 6.1+, and PostgreSQL 14+.
 
 * Bug Fixes *
-  -
+  - #5106, Fix segfault in ST_RemEdgeNewFace/ST_RemEdgeModFace
+           when no edge side-faces are found (Sandro Santilli)
 
 PostGIS 3.2.4
 2022/11/12
diff --git a/liblwgeom/lwgeom_topo.c b/liblwgeom/lwgeom_topo.c
index 2e862d6dc..1b5b4d062 100644
--- a/liblwgeom/lwgeom_topo.c
+++ b/liblwgeom/lwgeom_topo.c
@@ -4077,7 +4077,7 @@ _lwt_RemEdge( LWT_TOPOLOGY* topo, LWT_ELEMID edge_id, int modFace )
       if ( ! box1 ) {
         i = edge->face_left;
         _lwt_release_edges(edge, 1);
-        _lwt_release_faces(faces, nfaces);
+        if ( nfaces ) _lwt_release_faces(faces, nfaces);
         lwerror("corrupted topology: no face have face_id=%"
                 LWTFMT_ELEMID " (left face for edge %"
                 LWTFMT_ELEMID ")", i, edge_id);
@@ -4086,7 +4086,7 @@ _lwt_RemEdge( LWT_TOPOLOGY* topo, LWT_ELEMID edge_id, int modFace )
       if ( ! box2 ) {
         i = edge->face_right;
         _lwt_release_edges(edge, 1);
-        _lwt_release_faces(faces, nfaces);
+        if ( nfaces ) _lwt_release_faces(faces, nfaces);
         lwerror("corrupted topology: no face have face_id=%"
                 LWTFMT_ELEMID " (right face for edge %"
                 LWTFMT_ELEMID ")", i, edge_id);
diff --git a/topology/test/regress/st_remedgemodface.sql b/topology/test/regress/st_remedgemodface.sql
index a8ac67434..6eda5a743 100644
--- a/topology/test/regress/st_remedgemodface.sql
+++ b/topology/test/regress/st_remedgemodface.sql
@@ -414,7 +414,40 @@ DROP SCHEMA features CASCADE;
 -------------------------------------------------------------------------
 -------------------------------------------------------------------------
 
--- clean up
+
+-------------------------------------------------------------------------
+-- Test for https://trac.osgeo.org/postgis/ticket/5106
+-------------------------------------------------------------------------
+
+BEGIN;
+SELECT NULL FROM topology.CreateTopology('t5106');
+INSERT INTO t5106.node VALUES ( 1, NULL, 'POINT(0 0)' );
+-- Cannot reference non-existing faces w/out dropping
+-- these constraints
+ALTER TABLE t5106.edge_data DROP constraint left_face_exists;
+ALTER TABLE t5106.edge_data DROP constraint right_face_exists;
+INSERT INTO t5106.edge VALUES
+(
+	1, -- edge_id
+	1, 1, -- start/end node
+	1, -1, -- next left/right edge
+	1, 2, -- left/right faces (different, both non-0 and non existent)
+  'LINESTRING(0 0,10 0,10 10,0 0)'
+);
+DO $BODY$
+BEGIN
+	PERFORM ST_RemEdgeModFace('t5106', 1);
+	RAISE EXCEPTION '#5106 failed throwing an exception';
+EXCEPTION WHEN OTHERS THEN
+	RAISE EXCEPTION '#5106 threw: %', SQLERRM;
+END;
+$BODY$ LANGUAGE 'plpgsql';
+ROLLBACK;
+
+----------------------------
+-- Clean up
+----------------------------
+
 DROP FUNCTION save_edges();
 DROP FUNCTION check_edges(text);
 DROP FUNCTION save_faces();
diff --git a/topology/test/regress/st_remedgemodface_expected b/topology/test/regress/st_remedgemodface_expected
index 3ae4345d8..dc76f3452 100644
--- a/topology/test/regress/st_remedgemodface_expected
+++ b/topology/test/regress/st_remedgemodface_expected
@@ -194,3 +194,4 @@ RM(11)|P3|t
 RM(11)|P4|t
 RM(11)|P5|t
 Topology 'city_data' dropped
+ERROR:  #5106 threw: corrupted topology: no face have face_id=1 (left face for edge 1)
diff --git a/topology/test/regress/st_remedgenewface.sql b/topology/test/regress/st_remedgenewface.sql
index c5f5413ba..3d55b3958 100644
--- a/topology/test/regress/st_remedgenewface.sql
+++ b/topology/test/regress/st_remedgenewface.sql
@@ -414,7 +414,39 @@ DROP SCHEMA features CASCADE;
 -------------------------------------------------------------------------
 -------------------------------------------------------------------------
 
--- clean up
+-------------------------------------------------------------------------
+-- Test for https://trac.osgeo.org/postgis/ticket/5106
+-------------------------------------------------------------------------
+
+BEGIN;
+SELECT NULL FROM topology.CreateTopology('t5106');
+INSERT INTO t5106.node VALUES ( 1, NULL, 'POINT(0 0)' );
+-- Cannot reference non-existing faces w/out dropping
+-- these constraints
+ALTER TABLE t5106.edge_data DROP constraint left_face_exists;
+ALTER TABLE t5106.edge_data DROP constraint right_face_exists;
+INSERT INTO t5106.edge VALUES
+(
+	1, -- edge_id
+	1, 1, -- start/end node
+	1, -1, -- next left/right edge
+	1, 2, -- left/right faces (different, both non-0 and non existent)
+  'LINESTRING(0 0,10 0,10 10,0 0)'
+);
+DO $BODY$
+BEGIN
+	PERFORM topology.ST_RemEdgeNewFace('t5106', 1);
+	RAISE EXCEPTION '#5106 failed throwing an exception';
+EXCEPTION WHEN OTHERS THEN
+	RAISE EXCEPTION '#5106 threw: %', SQLERRM;
+END;
+$BODY$ LANGUAGE 'plpgsql';
+ROLLBACK;
+
+----------------------------
+-- Clean up
+----------------------------
+
 DROP FUNCTION save_edges();
 DROP FUNCTION check_edges(text);
 DROP FUNCTION save_faces();
diff --git a/topology/test/regress/st_remedgenewface_expected b/topology/test/regress/st_remedgenewface_expected
index 96eb15131..279e74c78 100644
--- a/topology/test/regress/st_remedgenewface_expected
+++ b/topology/test/regress/st_remedgenewface_expected
@@ -224,3 +224,4 @@ RN(11)|P3|t
 RN(11)|P4|t
 RN(11)|P5|t
 Topology 'city_data' dropped
+ERROR:  #5106 threw: corrupted topology: no face have face_id=1 (left face for edge 1)

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

Summary of changes:
 NEWS                                             |  5 ++--
 liblwgeom/lwgeom_topo.c                          |  4 +--
 topology/test/regress/st_remedgemodface.sql      | 35 +++++++++++++++++++++++-
 topology/test/regress/st_remedgemodface_expected |  1 +
 topology/test/regress/st_remedgenewface.sql      | 34 ++++++++++++++++++++++-
 topology/test/regress/st_remedgenewface_expected |  1 +
 6 files changed, 74 insertions(+), 6 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list