[SCM] PostGIS branch stable-3.5 updated. 3.5.0-10-g0b55ff427

git at osgeo.org git at osgeo.org
Fri Oct 11 01:02:58 PDT 2024


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.5 has been updated
       via  0b55ff4279d1b30d17b1e520ef8b5d466cdfd8e9 (commit)
      from  31993531006d95721bed3328d0d511e9d91f102e (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 0b55ff4279d1b30d17b1e520ef8b5d466cdfd8e9
Author: Sandro Santilli <strk at kbt.io>
Date:   Fri Oct 11 09:47:27 2024 +0200

    Fix crash in TopoGeo_addPoint
    
    Closes #5794 in 3.5 branch (3.5.1dev)
    Includes regress test

diff --git a/NEWS b/NEWS
index fd090c86d..60e268649 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ PostgreSQL 12-17 required. GEOS 3.8+ required. Proj 6.1+ required.
 
 * Bug fixes *
 
+- #5794, Fix crash in TopoGeo_addPoint (Sandro Santilli)
 - #5785, [raster] ST_MapAlgebra segfaults when expression references
          a supernumerary rast argument (Dian M Fay)
 - #5787, Check that ST_ChangeEdgeGeom doesn't change winding of rings
@@ -52,9 +53,9 @@ Andreas Schild (German Team)
            will need rebuilding to upgrade to new signature
            (Jan Tojnar)
   - #5496, ST_Clip all variants replaced, will require
-           rebuilding of materialized views that use them 
+           rebuilding of materialized views that use them
            (funding from The National Institute for Agricultural
-            and Food Research and Technology (INIA-CSIC)), 
+            and Food Research and Technology (INIA-CSIC)),
             Regina Obe)
   - #5659, ST_DFullyWithin behaviour has changed to
            be ST_Contains(ST_Buffer(A, R), B) (Paul Ramsey)
diff --git a/liblwgeom/topo/lwgeom_topo.c b/liblwgeom/topo/lwgeom_topo.c
index bfdcf137e..cf869bb1a 100644
--- a/liblwgeom/topo/lwgeom_topo.c
+++ b/liblwgeom/topo/lwgeom_topo.c
@@ -6427,7 +6427,7 @@ _lwt_SnapEdgeToExistingNode(
  * @param moved if not-null will be set to 0 if the point was added
  *              w/out any snapping or 1 otherwise.
  *
- * @return id of the new node or -1 on error
+ * @return id of the new node, 0 if no edge was found below tolerance or -1 on error
  *
  */
 static LWT_ELEMID
@@ -6454,6 +6454,12 @@ _lwt_SplitAllEdgesToNewNode(LWT_TOPOLOGY* topo, LWT_ISO_EDGE *edges, uint64_t nu
     sorted[j].ptr = e;
     sorted[j++].score = dist;
   }
+  if ( ! j )
+  {
+    lwfree(sorted);
+    return 0;
+  }
+
   num = j;
   qsort(sorted, num, sizeof(scored_pointer), compare_scored_pointer);
   edges2 = lwalloc(sizeof(LWT_ISO_EDGE)*num);
@@ -6760,7 +6766,8 @@ _lwt_AddPoint(LWT_TOPOLOGY* topo, LWPOINT* point, double tol, int
     id = _lwt_SplitAllEdgesToNewNode(topo, edges, num, lwgeom_as_lwpoint(pt), tol, moved);
     _lwt_release_edges(edges, num);
   }
-  else
+
+  if ( id == 0 )
   {
     /* The point is isolated, add it as such */
     /* TODO: pass 1 as last argument (skipChecks) ? */
diff --git a/topology/test/regress/topogeo_addpoint.sql b/topology/test/regress/topogeo_addpoint.sql
index 1d5ad1894..a454cc711 100644
--- a/topology/test/regress/topogeo_addpoint.sql
+++ b/topology/test/regress/topogeo_addpoint.sql
@@ -78,3 +78,11 @@ SELECT 't5698', 'E', TopoGeo_addLinestring('t', 'LINESTRING( 15.796760167740288
 SELECT 't5698', 'N', TopoGeo_addPoint( 't', 'POINT(15.796760167739626 69.05714853429157)');
 SELECT 't5698', 'V', * FROM ValidateTopology('t');
 SELECT NULL FROM DropTopology('t');
+
+-- See https://trac.osgeo.org/postgis/ticket/5794
+BEGIN;
+SELECT NULL FROM topology.CreateTopology ('t');
+SELECT NULL FROM topology.TopoGeo_addLinestring('t', 'LINESTRING(0 0, 10 0)');
+SELECT 't5794', 'N', topology.TopoGeo_addPoint('t', 'POINT(9 5)', 5);
+SELECT 't5794', 'V', * FROM ValidateTopology('t');
+ROLLBACK;
diff --git a/topology/test/regress/topogeo_addpoint_expected b/topology/test/regress/topogeo_addpoint_expected
index bf28121eb..727560e08 100644
--- a/topology/test/regress/topogeo_addpoint_expected
+++ b/topology/test/regress/topogeo_addpoint_expected
@@ -32,3 +32,4 @@ tt5394|E2|2
 tt5394|N|3
 t5698|E|1
 t5698|N|3
+t5794|N|3

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

Summary of changes:
 NEWS                                            |  5 +++--
 liblwgeom/topo/lwgeom_topo.c                    | 11 +++++++++--
 topology/test/regress/topogeo_addpoint.sql      |  8 ++++++++
 topology/test/regress/topogeo_addpoint_expected |  1 +
 4 files changed, 21 insertions(+), 4 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list