[postgis-tickets] [SCM] PostGIS branch stable-2.4 updated. d35888bc6e787c37f3e393405ffc1792f1c5fce2
git at osgeo.org
git at osgeo.org
Mon Jun 29 02:55:38 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 d35888bc6e787c37f3e393405ffc1792f1c5fce2 (commit)
via 03e71313c564f735b3b0cf98849f02dff6f048e5 (commit)
via 40c8a06d838ace80a9fd0f69dd835063bb437261 (commit)
from 40b18b9fdec5fa86a5c78884b33a2d653bbe2e34 (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 d35888bc6e787c37f3e393405ffc1792f1c5fce2
Author: Sandro Santilli <strk at kbt.io>
Date: Mon Jun 29 11:53:31 2020 +0200
Add NEWS section
diff --git a/NEWS b/NEWS
index 2590837..4f36151 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ PostGIS 2.4.9
* Bug Fixes and Enhancements *
+ - #4709, Fix crash in adding edge to corrupted topology, (Sandro Santilli)
+ - Handle non-closed edge rings by human readable error (Sandro Santilli)
- #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)
commit 03e71313c564f735b3b0cf98849f02dff6f048e5
Author: Sandro Santilli <strk at kbt.io>
Date: Mon Jun 29 11:14:07 2020 +0200
Handle non-closed edge rings by human readable error
Handle both topological and geometrical corruption
Have getRingEdges raise an error if topology is corrupted
Includes test.
References #4709 in 2.4 branch
diff --git a/topology/postgis_topology.c b/topology/postgis_topology.c
index 5718b88..3e1a2f0 100644
--- a/topology/postgis_topology.c
+++ b/topology/postgis_topology.c
@@ -1115,6 +1115,41 @@ cb_getRingEdges(const LWT_BE_TOPOLOGY* topo,
edges[i] = val;
POSTGIS_DEBUGF(1, "Component %d in ring of edge %" LWTFMT_ELEMID
" is edge %d", i, edge, val);
+
+ /* For the last entry, check that we returned back to start
+ * point, or complain about topology being corrupted */
+ if ( i == *numelems - 1 )
+ {
+ int32 nextedge;
+ int sidecol = val > 0 ? 3 : 4;
+ const char *sidetext = val > 0 ? "left" : "right";
+
+ dat = SPI_getbinval(row, rowdesc, sidecol, &isnull);
+ if ( isnull )
+ {
+ lwfree(edges);
+ cberror(topo->be_data, "Edge %d" /*LWTFMT_ELEMID*/
+ " has NULL next_%s_edge",
+ val, sidetext);
+ *numelems = UINT64_MAX;
+ return NULL;
+ }
+ nextedge = DatumGetInt32(dat);
+ POSTGIS_DEBUGF(1, "Last component in ring of edge %"
+ LWTFMT_ELEMID " (%" LWTFMT_ELEMID ") has next_%s_edge %d",
+ edge, val, sidetext, nextedge);
+ if ( nextedge != edge )
+ {
+ lwfree(edges);
+ cberror(topo->be_data, "Corrupted topology: ring of edge %"
+ LWTFMT_ELEMID " is topologically non-closed",
+ edge);
+ *numelems = UINT64_MAX;
+ return NULL;
+ }
+ }
+
+
}
SPI_freetuptable(SPI_tuptable);
diff --git a/topology/test/regress/st_addedgemodface.sql b/topology/test/regress/st_addedgemodface.sql
index 25881cf..f6a5c81 100644
--- a/topology/test/regress/st_addedgemodface.sql
+++ b/topology/test/regress/st_addedgemodface.sql
@@ -521,6 +521,23 @@ SELECT f.id, r.element_type||':'||r.element_id as comp
SELECT 'F'||face_id, st_astext(mbr) FROM city_data.face ORDER BY face_id;
+-----------------------------------------------------
+-- Check robustness in presence of corrupted topology
+-----------------------------------------------------
+
+-- See https://trac.osgeo.org/postgis/ticket/4709
+BEGIN; -- need a transaction to corrupt the topology
+-- 1. Corrupt topology by setting edge 5 next_face_right = 999999 (instead of 5)
+UPDATE city_data.edge_data
+ SET
+ next_left_edge = 999999,
+ abs_next_left_edge = 999999
+ WHERE edge_id = 5; -- corrupt topology
+-- 2. Try to add an edge closing a ring involving edge 5
+-- 5 | POINT(36 38)
+-- 7 | POINT(41 40)
+SELECT ST_AddEdgeModFace('city_data', 5, 7, 'LINESTRING(36 38,41 40)');
+ROLLBACK; -- restores the topology
---------------------------------------------------------------------
-- Cleanups
diff --git a/topology/test/regress/st_addedgemodface_expected b/topology/test/regress/st_addedgemodface_expected
index cb03d42..92d99e6 100644
--- a/topology/test/regress/st_addedgemodface_expected
+++ b/topology/test/regress/st_addedgemodface_expected
@@ -208,4 +208,7 @@ F32|POLYGON((36 33,36 38,57 38,57 33,36 33))
F33|POLYGON((38 40,38 43,41 43,41 40,38 40))
F34|POLYGON((35 25,35 45,63 45,63 25,35 25))
F35|POLYGON((9 14,9 22,21 22,21 14,9 14))
+BEGIN
+ERROR: Backend error (no ring edges for edge 58): Corrupted topology: ring of edge 58 is topologically non-closed
+COMMIT
Topology 'city_data' dropped
commit 40c8a06d838ace80a9fd0f69dd835063bb437261
Author: Sandro Santilli <strk at kbt.io>
Date: Mon Jun 29 11:11:37 2020 +0200
Fix release of unexpected number of edges from a returned edge ring
Closes #4709 in 2.4 branch
diff --git a/liblwgeom/lwgeom_topo.c b/liblwgeom/lwgeom_topo.c
index 6aa8936..c55f949 100644
--- a/liblwgeom/lwgeom_topo.c
+++ b/liblwgeom/lwgeom_topo.c
@@ -1839,7 +1839,7 @@ _lwt_AddFaceSplit( LWT_TOPOLOGY* topo,
else if ( i != numedges )
{
lwfree( signed_edge_ids );
- _lwt_release_edges(ring_edges, numedges);
+ _lwt_release_edges(ring_edges, i);
lwerror("Unexpected error: %d edges found when expecting %d", i, numedges);
return -2;
}
-----------------------------------------------------------------------
Summary of changes:
NEWS | 2 ++
liblwgeom/lwgeom_topo.c | 2 +-
topology/postgis_topology.c | 35 ++++++++++++++++++++++++
topology/test/regress/st_addedgemodface.sql | 17 ++++++++++++
topology/test/regress/st_addedgemodface_expected | 3 ++
5 files changed, 58 insertions(+), 1 deletion(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list