[SCM] PostGIS branch master updated. 3.7.0beta1-103-g5e47d8c16f

git at osgeo.org git at osgeo.org
Mon Jul 27 16:42:31 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  5e47d8c16f78442f9a2c7fbb8953a3c89da6a4a2 (commit)
       via  876b42753d19dfe7ab2c684db7801f2908e89e3c (commit)
      from  f7c211c2f14f0b74a8da35d5ef9de9bc962de4cc (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 5e47d8c16f78442f9a2c7fbb8953a3c89da6a4a2
Merge: f7c211c2f1 876b42753d
Author: Darafei Praliaskouski <komzpa at gmail.com>
Date:   Mon Jul 27 16:42:30 2026 -0700

    Merge pull request 'Fix ST_MakePolygon with NULL holes' (!564) from Komzpa/postgis:fix/makepolygon-null-holes-master into master
    
    Reviewed-on: https://gitea.osgeo.org/postgis/postgis/pulls/564


commit 876b42753d19dfe7ab2c684db7801f2908e89e3c
Author: Darafei Praliaskouski <me at komzpa.net>
Date:   Tue Jul 28 01:47:19 2026 +0400

    Fix ST_MakePolygon with NULL holes

diff --git a/NEWS b/NEWS
index 089d6dc770..43aa95bd86 100644
--- a/NEWS
+++ b/NEWS
@@ -20,6 +20,8 @@ These are only changes since 3.7.0beta1.
           (Arthur Bazin)
  - GT-521, Reject malformed GSERIALIZED payload counts before deserializing
           geometry data (Darafei Praliaskouski)
+ - GT-564, Avoid ST_MakePolygon failures with NULL hole array entries
+          (Darafei Praliaskouski)
 
 * Enhancements *
 
diff --git a/postgis/lwgeom_functions_basic.c b/postgis/lwgeom_functions_basic.c
index f12b04b5c1..3c46eb9d1a 100644
--- a/postgis/lwgeom_functions_basic.c
+++ b/postgis/lwgeom_functions_basic.c
@@ -1583,8 +1583,8 @@ Datum LWGEOM_makepoly(PG_FUNCTION_ARGS)
 	LWPOLY *outpoly;
 	LWCURVEPOLY *outcurvepoly;
 	uint32 nholes = 0;
+	uint32 nitems = 0;
 	uint32 i;
-	size_t offset = 0;
 	int has_curve_ring = LW_FALSE;
 	int32_t srid;
 	int has_z;
@@ -1607,31 +1607,34 @@ Datum LWGEOM_makepoly(PG_FUNCTION_ARGS)
 	/* Get input holes if any */
 	if (PG_NARGS() > 1)
 	{
+		ArrayIterator iterator;
+		Datum value;
+		bool isnull;
+
 		array = PG_GETARG_ARRAYTYPE_P(1);
-		nholes = ArrayGetNItems(ARR_NDIM(array), ARR_DIMS(array));
-		rings = lwalloc(sizeof(LWGEOM *) * (nholes + 1));
-		holes = lwalloc(sizeof(LWLINE *) * nholes);
-		for (i = 0; i < nholes; i++)
+		nitems = ArrayGetNItems(ARR_NDIM(array), ARR_DIMS(array));
+		rings = lwalloc(sizeof(LWGEOM *) * (nitems + 1));
+		holes = lwalloc(sizeof(LWLINE *) * nitems);
+		iterator = array_create_iterator(array, 0, NULL);
+		while (array_iterate(iterator, &value, &isnull))
 		{
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wsign-compare"
-#endif
-			GSERIALIZED *g = (GSERIALIZED *)(ARR_DATA_PTR(array) + offset);
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
-#pragma GCC diagnostic pop
-#endif
+			GSERIALIZED *g;
 			LWGEOM *hole;
-			offset += INTALIGN(VARSIZE(g));
+
+			if (isnull)
+				continue;
+
+			g = (GSERIALIZED *)DatumGetPointer(value);
 			if (!lwgeom_is_makepoly_ring_type(gserialized_get_type(g)))
 			{
-				lwpgerror("Hole %d is not a line", i);
+				lwpgerror("Hole %d is not a line", nholes);
 			}
 			hole = lwgeom_from_gserialized(g);
 			has_curve_ring |= hole->type != LINETYPE;
-			rings[i + 1] = hole;
-			holes[i] = lwgeom_as_lwline(hole);
+			rings[nholes + 1] = hole;
+			holes[nholes++] = lwgeom_as_lwline(hole);
 		}
+		array_free_iterator(iterator);
 	}
 
 	if (has_curve_ring)
diff --git a/regress/core/tickets.sql b/regress/core/tickets.sql
index dd22ce5a04..fd03131cee 100644
--- a/regress/core/tickets.sql
+++ b/regress/core/tickets.sql
@@ -1808,3 +1808,8 @@ DROP TABLE IF EXISTS fault6028;
 
 -- #5357
 SELECT '#5357', ST_AsText(ST_LineFromEncodedPolyline('__nphBgcoeiA?@', 6), 6);
+
+-- ST_MakePolygon with NULL holes
+SELECT 'makepolygon-null-holes', ST_NPoints(ST_MakePolygon(
+	'LINESTRING ZM (0 0 0 0,0 1 0 0,1 1 0 0,0 0 0 0)'::geometry,
+	ARRAY[NULL::geometry]));
diff --git a/regress/core/tickets_expected b/regress/core/tickets_expected
index c580547f4c..f6b6ec305c 100644
--- a/regress/core/tickets_expected
+++ b/regress/core/tickets_expected
@@ -525,3 +525,4 @@ public|test5978|shape|2|4326|POINT
 #5938|1FF00F212|t
 1|01030000209713000000000000
 #5357|LINESTRING(38.903876 55.336448,38.903875 55.336448)
+makepolygon-null-holes|4

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

Summary of changes:
 NEWS                             |  2 ++
 postgis/lwgeom_functions_basic.c | 37 ++++++++++++++++++++-----------------
 regress/core/tickets.sql         |  5 +++++
 regress/core/tickets_expected    |  1 +
 4 files changed, 28 insertions(+), 17 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list