[SCM] PostGIS branch stable-3.0 updated. 3.0.11-16-g7021871bd

git at osgeo.org git at osgeo.org
Thu Jun 5 00:58:26 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.0 has been updated
       via  7021871bda202171b44a3bab975b194987c98d1a (commit)
      from  d40d7a73958fbbbc2819737ce1f846f8fb7122c2 (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 7021871bda202171b44a3bab975b194987c98d1a
Author: Sandro Santilli <strk at kbt.io>
Date:   Thu Jun 5 09:15:12 2025 +0200

    Fix crash on TopoGeo_addLineString(empty)
    
    Closes #5922 in 3.0 branch (3.0.12dev)

diff --git a/NEWS b/NEWS
index 293ba710b..eddf73244 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ Proj 4.9+ required.
 
 * Bug Fixes *
 
+ - #5922, [topology] Fix crash in TopoGeo_AddLinestring with EMPTY input (Sandro Santilli)
  - #5907, [topology] Fix crash in TopoGeo_AddPolygon with EMPTY input (Sandro Santilli)
  - #5795, [topology] Fix ST_NewEdgesSplit can cause invalid topology (Björn Harrtell)
  - Handle null returns from wkb parser, Paul Ramsey
diff --git a/liblwgeom/lwgeom_topo.c b/liblwgeom/lwgeom_topo.c
index 1a5e594eb..4941851ce 100644
--- a/liblwgeom/lwgeom_topo.c
+++ b/liblwgeom/lwgeom_topo.c
@@ -5541,6 +5541,12 @@ _lwt_AddLine(LWT_TOPOLOGY* topo, LWLINE* line, double tol, int* nedges,
   uint64_t i;
   GBOX qbox;
 
+  if ( lwline_is_empty(line) )
+  {
+    *nedges = 0;
+    return NULL;
+  }
+
   *nedges = -1; /* error condition, by default */
 
   /* Get tolerance, if 0 was given */
diff --git a/topology/postgis_topology.c b/topology/postgis_topology.c
index 07f1c0222..4e1f6a51e 100644
--- a/topology/postgis_topology.c
+++ b/topology/postgis_topology.c
@@ -4795,6 +4795,13 @@ Datum TopoGeo_AddLinestring(PG_FUNCTION_ARGS)
         PG_RETURN_NULL();
       }
     }
+    /* Nothing to do if line is empty */
+    if ( lwline_is_empty(ln) )
+    {
+      lwgeom_free(lwgeom);
+      PG_FREE_IF_COPY(geom, 1);
+      PG_RETURN_NULL();
+    }
 
     tol = PG_GETARG_FLOAT8(2);
     if ( tol < 0 )
diff --git a/topology/test/regress/topogeo_addlinestring.sql b/topology/test/regress/topogeo_addlinestring.sql
index a6f2caeba..df9ea57ec 100644
--- a/topology/test/regress/topogeo_addlinestring.sql
+++ b/topology/test/regress/topogeo_addlinestring.sql
@@ -59,6 +59,7 @@ $$ LANGUAGE 'plpgsql';
 SELECT 'invalid', TopoGeo_addLineString('city_data', 'SRID=4326;MULTILINESTRING((36 26, 38 30))');
 SELECT 'invalid', TopoGeo_addLineString('city_data', 'SRID=4326;POINT(36 26)');
 SELECT 'invalid', TopoGeo_addLineString('invalid', 'SRID=4326;LINESTRING(36 26, 0 0)');
+SELECT 'empty', TopoGeo_addLineString('city_data', 'SRID=4326;LINESTRING EMPTY');
 
 -- Isolated edge in universal face
 SELECT 'iso_uni', TopoGeo_addLineString('city_data', 'SRID=4326;LINESTRING(36 26, 38 30)');
diff --git a/topology/test/regress/topogeo_addlinestring_expected b/topology/test/regress/topogeo_addlinestring_expected
index 11f9e50cd..36b6c314b 100644
--- a/topology/test/regress/topogeo_addlinestring_expected
+++ b/topology/test/regress/topogeo_addlinestring_expected
@@ -7,6 +7,7 @@ max|edge|26
 ERROR:  Invalid geometry type (MULTILINESTRING) passed to TopoGeo_AddLinestring, expected LINESTRING
 ERROR:  Invalid geometry type (POINT) passed to TopoGeo_AddLinestring, expected LINESTRING
 ERROR:  No topology with name "invalid" in topology.topology
+empty|
 iso_uni|27
 iso_uni|N||POINT(36 26)
 iso_uni|N||POINT(38 30)

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

Summary of changes:
 NEWS                                                 | 1 +
 liblwgeom/lwgeom_topo.c                              | 6 ++++++
 topology/postgis_topology.c                          | 7 +++++++
 topology/test/regress/topogeo_addlinestring.sql      | 1 +
 topology/test/regress/topogeo_addlinestring_expected | 1 +
 5 files changed, 16 insertions(+)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list