[postgis-tickets] [SCM] PostGIS branch stable-3.0 updated. 3.0.1-19-gab4f540

git at osgeo.org git at osgeo.org
Fri Jun 19 07:32:52 PDT 2020


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.0 has been updated
       via  ab4f540a7a2e9facb2ed5c08df8f11002f71fa37 (commit)
      from  0d4b572fae826841c26a4fbd65abfc76394d4df9 (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 ab4f540a7a2e9facb2ed5c08df8f11002f71fa37
Author: Sandro Santilli <strk at kbt.io>
Date:   Fri Jun 19 15:58:48 2020 +0200

    Handle corrupted topology in ST_ChangeEdgeGeom
    
    Rather than crashing the backend.
    References #4706 in 3.0 branch
    Include tests.

diff --git a/NEWS b/NEWS
index f73b9b2..f97f0bf 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@ PostGIS 3.0.2
 2020/XX/XX
 
 * Bug Fixes and Enhancements *
+  - #4706, Fix crash in ST_ChangeEdgeGeom on corrupted topology (Sandro Santilli)
   - #4652, Fix several memory related bugs in ST_GeomFromGML (Raúl Marín)
   - #4661, Fix access to spatial_ref_sys with a non default schema (Raúl Marín)
   - #4670, ST_AddPoint: Fix bug when a positive position is requested (Raúl Marín)
diff --git a/liblwgeom/lwgeom_topo.c b/liblwgeom/lwgeom_topo.c
index 672870d..0926888 100644
--- a/liblwgeom/lwgeom_topo.c
+++ b/liblwgeom/lwgeom_topo.c
@@ -3462,6 +3462,12 @@ lwt_ChangeEdgeGeom(LWT_TOPOLOGY* topo, LWT_ELEMID edge_id, LWLINE *geom)
       }
   #endif
       lwgeom_add_bbox(nface1);
+      if ( ! nface1->bbox )
+      {
+        lwerror("Corrupted topology: face %d, left of edge %d, has no bbox",
+          oldedge->face_left, edge_id);
+        return -1;
+      }
       faces[facestoupdate].face_id = oldedge->face_left;
       /* ownership left to nface */
       faces[facestoupdate++].mbr = nface1->bbox;
@@ -3487,6 +3493,12 @@ lwt_ChangeEdgeGeom(LWT_TOPOLOGY* topo, LWT_ELEMID edge_id, LWLINE *geom)
       }
   #endif
       lwgeom_add_bbox(nface2);
+      if ( ! nface2->bbox )
+      {
+        lwerror("Corrupted topology: face %d, right of edge %d, has no bbox",
+          oldedge->face_right, edge_id);
+        return -1;
+      }
       faces[facestoupdate].face_id = oldedge->face_right;
       faces[facestoupdate++].mbr = nface2->bbox; /* ownership left to nface */
     }
diff --git a/topology/test/regress/st_changeedgegeom.sql b/topology/test/regress/st_changeedgegeom.sql
index 84a92ae..7579449 100644
--- a/topology/test/regress/st_changeedgegeom.sql
+++ b/topology/test/regress/st_changeedgegeom.sql
@@ -135,6 +135,14 @@ SELECT 'T13.2', ST_ChangeEdgeGeom('city_data', 29, '010200000008000000E42CEC6987
 SELECT 'T13.3', TopoGeo_AddPoint('city_data', 'POINT(-1.1697 47.7825)'::geometry);
 SELECT 'T13.4', ST_ChangeEdgeGeom('city_data', 29, '01020000001D000000E42CEC69873FF2BF9E98F56228E347400EDB16653648F2BF4985B18520E34740E92B4833164DF2BF3A1E335019E34740A94D9CDCEF50F2BF33F9669B1BE347407DAEB6627F59F2BF2CF180B229E34740758E01D9EB5DF2BFD0D556EC2FE34740533F6F2A5261F2BFD717096D39E34740F4893C49BA66F2BFC8073D9B55E34740B8239C16BC68F2BF33A7CB6262E34740AA2B9FE57970F2BF4165FCFB8CE347406DC5FEB27B72F2BFBA4E232D95E34740978BF84ECC7AF2BF24EEB1F4A1E34740E527D53E1D8FF2BF8F8D40BCAEE3474036CD3B4ED191F2BF649291B3B0E34740841266DAFE95F2BF1DE6CB0BB0E34740E3361AC05BA0F2BFB2632310AFE347405C5A0D897BACF2BF72F90FE9B7E3474031D3F6AFACB4F2BF4F232D95B7E347402B137EA99FB7F2BFD656EC2FBBE347402D431CEBE2B6F2BF551344DD07E4474011E4A08499B6F2BF15E3FC4D28E447406519E25817B7F2BF63EE5A423EE447409DD7D825AAB7F2BFE3FC4D2844E447405969520ABABDF2BF2384471B47E44740A31EA2D11DC4F2BFB1F9B83654E447400473F4F8BDCDF2BFEA5BE67459E447405070B1A206D3F2BFF19D98F562E4474062670A9DD7D8F2BF0E4FAF9465E447407FF6234564D8F2BFF1BA7EC16EE4474
 0' );
 
+-- See https://trac.osgeo.org/postgis/ticket/4706
+-- 1. Corrupt topology by setting edge 19 face_right = 3 (instead of 4)
+UPDATE city_data.edge_data SET right_face = 3 WHERE edge_id = 19; -- corrupt topology
+-- 2. Try to change the edge of a face with no bbox
+SELECT ST_ChangeEdgeGeom('city_data', 7, 'LINESTRING(21 22,28 20,35 22)' );
+-- 3. Restore topology
+UPDATE city_data.edge_data SET right_face = 4 WHERE edge_id = 19; -- restore topology
+
 -- TODO: test changing some clockwise closed edges..
 
 SELECT topology.DropTopology('city_data');
diff --git a/topology/test/regress/st_changeedgegeom_expected b/topology/test/regress/st_changeedgegeom_expected
index 155f1b8..487cbc8 100644
--- a/topology/test/regress/st_changeedgegeom_expected
+++ b/topology/test/regress/st_changeedgegeom_expected
@@ -39,4 +39,5 @@ T13.1|29
 T13.2|Edge 29 changed
 T13.3|26
 ERROR:  Edge motion collision at POINT(-1.1697 47.7825)
+ERROR:  Corrupted topology: face 4, right of edge 7, has no bbox
 Topology 'city_data' dropped

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

Summary of changes:
 NEWS                                             |  1 +
 liblwgeom/lwgeom_topo.c                          | 12 ++++++++++++
 topology/test/regress/st_changeedgegeom.sql      |  8 ++++++++
 topology/test/regress/st_changeedgegeom_expected |  1 +
 4 files changed, 22 insertions(+)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list