[SCM] PostGIS branch master updated. 3.5.0-19-gcfc46e464

git at osgeo.org git at osgeo.org
Fri Oct 11 00:59:07 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, master has been updated
       via  cfc46e4641c1fa7b3b391e3846ae3a2f79cd07b7 (commit)
      from  b0f0182dc0a8157e2da3d411165eac0113631799 (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 cfc46e4641c1fa7b3b391e3846ae3a2f79cd07b7
Author: Sandro Santilli <strk at kbt.io>
Date:   Fri Oct 11 09:47:27 2024 +0200

    Fix crash in TopoGeo_addPoint
    
    References #5794 in master branch (3.6.0dev)
    Includes regress test

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:
 liblwgeom/topo/lwgeom_topo.c                    | 11 +++++++++--
 topology/test/regress/topogeo_addpoint.sql      |  8 ++++++++
 topology/test/regress/topogeo_addpoint_expected |  1 +
 3 files changed, 18 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list