[SCM] PostGIS branch stable-3.2 updated. 3.2.7-45-ge03eb8e19
git at osgeo.org
git at osgeo.org
Sat Jul 19 01:56:56 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, stable-3.2 has been updated
via e03eb8e19d03d21c2af9e5346dec9c11458a5080 (commit)
from 15fa2f12ba9150a93d4d4c3d4075df0504a96fe5 (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 e03eb8e19d03d21c2af9e5346dec9c11458a5080
Author: Sandro Santilli <strk at kbt.io>
Date: Sat Jul 19 09:47:42 2025 +0200
Have GetFaceContainingPoint catch EMPTY edges in corrupted topology
Fixes #5925, #5946 in 3.2 branch (3.2.9dev)
Includes regression test
diff --git a/NEWS b/NEWS
index 0e824d550..3e946a8df 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ Proj 4.9+ required.
* Bug Fixes *
+ - #5925, #5946, [topology] Have GetFaceContainingPoint survive EMPTY edges (Sandro Santilli)
- #5922, [topology] Fix crash in TopoGeo_AddLinestring with EMPTY input (Sandro Santilli)
- #5908, [topology] Fix crash in GetFaceContainingPoint (Sandro Santilli)
- #5907, [topology] Fix crash in TopoGeo_AddPolygon with EMPTY input (Sandro Santilli)
diff --git a/liblwgeom/lwgeom_topo.c b/liblwgeom/lwgeom_topo.c
index f7a00f380..8a52e6d53 100644
--- a/liblwgeom/lwgeom_topo.c
+++ b/liblwgeom/lwgeom_topo.c
@@ -7137,6 +7137,30 @@ lwt_GetFaceContainingPoint(LWT_TOPOLOGY* topo, const LWPOINT* pt)
return 0;
}
+ if ( closestEdge->face_left < 0 )
+ {
+ lwerror("Closest edge %" LWTFMT_ELEMID " has invalid face %" LWTFMT_ELEMID
+ " on its left side", closestEdge->edge_id, closestEdge->face_left);
+ _lwt_release_edges(closestEdge, 1);
+ return -1;
+ }
+
+ if ( closestEdge->face_right < 0 )
+ {
+ lwerror("Closest edge %" LWTFMT_ELEMID " has invalid face %" LWTFMT_ELEMID
+ " on its right side", closestEdge->edge_id, closestEdge->face_right);
+ _lwt_release_edges(closestEdge, 1);
+ return -1;
+ }
+
+ if ( closestEdge->geom->points->npoints < 2 )
+ {
+ lwerror("Corrupted topology: geometry of edge %" LWTFMT_ELEMID " is EMPTY",
+ closestEdge->edge_id);
+ _lwt_release_edges(closestEdge, 1);
+ return -1;
+ }
+
LWDEBUGGF(2, lwline_as_lwgeom(closestEdge->geom), "Closest edge %" LWTFMT_ELEMID, closestEdge->edge_id);
/* Find closest segment of edge to the point */
diff --git a/topology/test/regress/getfacebypoint.sql b/topology/test/regress/getfacebypoint.sql
index 7c67bf944..842394cb8 100644
--- a/topology/test/regress/getfacebypoint.sql
+++ b/topology/test/regress/getfacebypoint.sql
@@ -57,4 +57,11 @@ SELECT 'e1', topology.GetFaceByPoint('topo','POINT(1 5)', 0);
-- Ask for a Point with a tollerance too high (2 or more faces)
SELECT 'e2', topology.GetFaceByPoint('topo','POINT(6 13)', 1);
+-- Empty edge geometries should not make the function choke
+-- See https://trac.osgeo.org/postgis/ticket/5946
+BEGIN;
+UPDATE topo.edge_data SET geom = 'LINESTRING EMPTY';
+SELECT 't5946', topology.GetFaceByPoint('topo','POINT(6 13)', 0);
+ROLLBACK;
+
SELECT NULL FROM topology.DropTopology('topo');
diff --git a/topology/test/regress/getfacebypoint_expected b/topology/test/regress/getfacebypoint_expected
index 5dfc9116f..bc4c894d8 100644
--- a/topology/test/regress/getfacebypoint_expected
+++ b/topology/test/regress/getfacebypoint_expected
@@ -10,3 +10,4 @@ t4|0
t5|t
ERROR: Two or more faces found
ERROR: Two or more faces found
+ERROR: Corrupted topology: geometry of edge 14 is EMPTY
diff --git a/topology/test/regress/topogeo_addpoint.sql b/topology/test/regress/topogeo_addpoint.sql
index 3f7cd3e80..e164c15e4 100644
--- a/topology/test/regress/topogeo_addpoint.sql
+++ b/topology/test/regress/topogeo_addpoint.sql
@@ -64,3 +64,10 @@ SELECT 'tt2033', 'N' || topogeo_addpoint('t', 'POINT(0.2 1 1)', 0.5);
SELECT 'tt2033', 'NC', node_id, ST_AsText(geom) FROM t.node ORDER BY node_id;
SELECT 'tt2033.end' || DropTopology('t');
+-- See https://trac.osgeo.org/postgis/ticket/5925
+BEGIN;
+SELECT NULL FROM topology.CreateTopology ('t');
+SELECT NULL FROM topology.TopoGeo_addLinestring('t', 'LINESTRING(0 0, 10 0)');
+UPDATE t.edge_data SET geom = 'LINESTRING EMPTY';
+SELECT 't5925.1', topology.TopoGeo_addPoint('t', 'POINT(5 5)', 0);
+ROLLBACK;
diff --git a/topology/test/regress/topogeo_addpoint_expected b/topology/test/regress/topogeo_addpoint_expected
index fdc50c387..85c33e269 100644
--- a/topology/test/regress/topogeo_addpoint_expected
+++ b/topology/test/regress/topogeo_addpoint_expected
@@ -27,3 +27,4 @@ tt2033|NC|1|POINT Z (0 0 0)
tt2033|NC|2|POINT Z (0 2 1)
tt2033|NC|3|POINT Z (0 1 1)
tt2033.endTopology 't' dropped
+ERROR: Corrupted topology: geometry of edge 1 is EMPTY
-----------------------------------------------------------------------
Summary of changes:
NEWS | 1 +
liblwgeom/lwgeom_topo.c | 24 ++++++++++++++++++++++++
topology/test/regress/getfacebypoint.sql | 7 +++++++
topology/test/regress/getfacebypoint_expected | 1 +
topology/test/regress/topogeo_addpoint.sql | 7 +++++++
topology/test/regress/topogeo_addpoint_expected | 1 +
6 files changed, 41 insertions(+)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list