[SCM] PostGIS branch master updated. 3.6.0rc2-587-g9b9950de1

git at osgeo.org git at osgeo.org
Thu Jun 18 05:36:18 PDT 2026


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  9b9950de1262a24c41e9e4d647627b1816a6ac52 (commit)
       via  9cc6dac3d6d9c119667a438118cb4b5b6bb21c3b (commit)
      from  014d02c42befac740f904b1cceca52391b671097 (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 9b9950de1262a24c41e9e4d647627b1816a6ac52
Merge: 014d02c42 9cc6dac3d
Author: Darafei Praliaskouski <me at komzpa.net>
Date:   Thu Jun 18 16:27:57 2026 +0400

    Merge PR #888: Fix SFCGAL visibility empty input handling
    
    Avoid stale detoasted geometry access in CG_Visibility empty-input compatibility handling for builds against SFCGAL before 2.2, while preserving the empty polygon result for empty inputs.


commit 9cc6dac3d6d9c119667a438118cb4b5b6bb21c3b
Author: Darafei Praliaskouski <me at komzpa.net>
Date:   Tue Jun 16 17:15:54 2026 +0400

    Fix SFCGAL visibility empty input handling

diff --git a/NEWS b/NEWS
index 4cd72746a..cf06261d4 100644
--- a/NEWS
+++ b/NEWS
@@ -54,6 +54,9 @@ To take advantage of all postgis_sfcgal extension features SFCGAL 2.3+ is needed
           finite coordinates (Darafei Praliaskouski)
  - GH-892, Add OSS-Fuzz coverage for TWKB and serialized raster inputs,
           including guards for malformed TWKB reads and counts (Darafei Praliaskouski)
+ - GH-888, [sfcgal] Avoid stale detoasted geometry access in
+          CG_Visibility empty-input handling for SFCGAL < 2.2
+          (Darafei Praliaskouski)
  - Build PostgreSQL extension modules with `-fno-semantic-interposition` when
           available so LTO can optimize same-DSO calls to exported PostGIS
           entry points directly instead of routing through the module PLT; in
diff --git a/sfcgal/lwgeom_sfcgal.c b/sfcgal/lwgeom_sfcgal.c
index 5ee90f878..0289ccb21 100644
--- a/sfcgal/lwgeom_sfcgal.c
+++ b/sfcgal/lwgeom_sfcgal.c
@@ -19,6 +19,7 @@
  **********************************************************************
  *
  * Copyright 2012-2020 Oslandia <infos at oslandia.com>
+ * Copyright 2026 Darafei Praliaskouski <me at komzpa.net>
  *
  **********************************************************************/
 
@@ -1232,22 +1233,30 @@ sfcgal_visibility_point(PG_FUNCTION_ARGS)
 	input0 = PG_GETARG_GSERIALIZED_P(0);
 	srid = gserialized_get_srid(input0);
 	input1 = PG_GETARG_GSERIALIZED_P(1);
-	polygon = POSTGIS2SFCGALGeometry(input0);
-	PG_FREE_IF_COPY(input0, 0);
-	point = POSTGIS2SFCGALGeometry(input1);
-	PG_FREE_IF_COPY(input1, 1);
 
 #if POSTGIS_SFCGAL_VERSION < 20200
+	/*
+	 * SFCGAL < 2.2 needs PostGIS to preserve the empty-input result.
+	 * Check this before converting and freeing detoasted inputs, because
+	 * gserialized_is_empty() must not inspect a freed copy.
+	 */
 	if (gserialized_is_empty(input0) || gserialized_is_empty(input1))
 	{
 		result = sfcgal_polygon_create();
 		output = SFCGALGeometry2POSTGIS(result, 0, srid);
 		sfcgal_geometry_delete(result);
 
+		PG_FREE_IF_COPY(input0, 0);
+		PG_FREE_IF_COPY(input1, 1);
 		PG_RETURN_POINTER(output);
 	}
 #endif
 
+	polygon = POSTGIS2SFCGALGeometry(input0);
+	PG_FREE_IF_COPY(input0, 0);
+	point = POSTGIS2SFCGALGeometry(input1);
+	PG_FREE_IF_COPY(input1, 1);
+
 	result = sfcgal_geometry_visibility_point(polygon, point);
 	sfcgal_geometry_delete(polygon);
 	sfcgal_geometry_delete(point);
@@ -1282,24 +1291,33 @@ sfcgal_visibility_segment(PG_FUNCTION_ARGS)
 	srid = gserialized_get_srid(input0);
 	input1 = PG_GETARG_GSERIALIZED_P(1);
 	input2 = PG_GETARG_GSERIALIZED_P(2);
-	polygon = POSTGIS2SFCGALGeometry(input0);
-	PG_FREE_IF_COPY(input0, 0);
-	pointA = POSTGIS2SFCGALGeometry(input1);
-	PG_FREE_IF_COPY(input1, 1);
-	pointB = POSTGIS2SFCGALGeometry(input2);
-	PG_FREE_IF_COPY(input2, 2);
 
 #if POSTGIS_SFCGAL_VERSION < 20200
+	/*
+	 * SFCGAL < 2.2 needs PostGIS to preserve the empty-input result.
+	 * Check this before converting and freeing detoasted inputs, because
+	 * gserialized_is_empty() must not inspect a freed copy.
+	 */
 	if (gserialized_is_empty(input0) || gserialized_is_empty(input1) || gserialized_is_empty(input2))
 	{
 		result = sfcgal_polygon_create();
 		output = SFCGALGeometry2POSTGIS(result, 0, srid);
 		sfcgal_geometry_delete(result);
 
+		PG_FREE_IF_COPY(input0, 0);
+		PG_FREE_IF_COPY(input1, 1);
+		PG_FREE_IF_COPY(input2, 2);
 		PG_RETURN_POINTER(output);
 	}
 #endif
 
+	polygon = POSTGIS2SFCGALGeometry(input0);
+	PG_FREE_IF_COPY(input0, 0);
+	pointA = POSTGIS2SFCGALGeometry(input1);
+	PG_FREE_IF_COPY(input1, 1);
+	pointB = POSTGIS2SFCGALGeometry(input2);
+	PG_FREE_IF_COPY(input2, 2);
+
 	result = sfcgal_geometry_visibility_segment(polygon, pointA, pointB);
 	sfcgal_geometry_delete(polygon);
 	sfcgal_geometry_delete(pointA);

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

Summary of changes:
 NEWS                   |  3 +++
 sfcgal/lwgeom_sfcgal.c | 38 ++++++++++++++++++++++++++++----------
 2 files changed, 31 insertions(+), 10 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list