[postgis-tickets] [SCM] PostGIS branch stable-2.4 updated. 5b809e2d656d7b5d1d86f5f9a3647e8af5ef1fcd

git at osgeo.org git at osgeo.org
Fri Jun 19 07:42:04 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-2.4 has been updated
       via  5b809e2d656d7b5d1d86f5f9a3647e8af5ef1fcd (commit)
      from  99cd7a1a5af16370c24cac2ad398e4f557871243 (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 5b809e2d656d7b5d1d86f5f9a3647e8af5ef1fcd
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 2.4 branch.
    Include tests.

diff --git a/NEWS b/NEWS
index 1fd002b..2590837 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ PostGIS 2.4.9
 
   * Bug Fixes and Enhancements *
 
+  - #4706, Fix crash in ST_ChangeEdgeGeom on corrupted topology (Sandro Santilli)
   - #4480, Geography Distance inconsistent with Intersects (Paul Ramsey)
   - #4481, Improve libprotobuf detection for old systems (Paul Ramsey)
   - #4475, Avoid reading into empty ptarra (Paul Ramsey)
diff --git a/liblwgeom/lwgeom_topo.c b/liblwgeom/lwgeom_topo.c
index 17535cf..6aa8936 100644
--- a/liblwgeom/lwgeom_topo.c
+++ b/liblwgeom/lwgeom_topo.c
@@ -3624,6 +3624,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, right 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;
@@ -3649,6 +3655,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 a9e18b7..1a19a82 100644
--- a/topology/test/regress/st_changeedgegeom.sql
+++ b/topology/test/regress/st_changeedgegeom.sql
@@ -136,6 +136,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 102a322..4e16fc9 100644
--- a/topology/test/regress/st_changeedgegeom_expected
+++ b/topology/test/regress/st_changeedgegeom_expected
@@ -41,4 +41,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