[SCM] PostGIS branch stable-3.5 updated. 3.5.7-81-g1132702d6
git at osgeo.org
git at osgeo.org
Thu Jul 23 13:01:32 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, stable-3.5 has been updated
via 1132702d6b108279d0d66ed93dbdfef704e0e729 (commit)
via 822431278881b7eed51534c0c9991bb0a2883942 (commit)
from 9c0f513bcccdf519fc8639751aa30d4e6cf7f425 (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 1132702d6b108279d0d66ed93dbdfef704e0e729
Merge: 9c0f513bc 822431278
Author: Darafei Praliaskouski <komzpa at gmail.com>
Date: Thu Jul 23 13:01:31 2026 -0700
Merge pull request 'Fix ST_MakePolygon with NULL hole array entries' (!496) from Komzpa/postgis:ci/stable35-makepolygon-null-20260723 into stable-3.5
Reviewed-on: https://gitea.osgeo.org/postgis/postgis/pulls/496
commit 822431278881b7eed51534c0c9991bb0a2883942
Author: Darafei Praliaskouski <me at komzpa.net>
Date: Thu Jul 23 20:45:37 2026 +0400
Fix ST_MakePolygon with NULL holes
diff --git a/NEWS b/NEWS
index 6515cabf0..2c5e2ad05 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,8 @@ PostGIS 3.5.8
cancellation state (Darafei Praliaskouski)
- GH-1160, [topology] Preserve overlay intersection boundaries when
noding lines with GEOS main (Darafei Praliaskouski)
+ - GT-496, Avoid ST_MakePolygon crashes with NULL hole array entries
+ (Darafei Praliaskouski)
PostGIS 3.5.7
2026/06/10
diff --git a/postgis/lwgeom_functions_basic.c b/postgis/lwgeom_functions_basic.c
index 1e126ce82..0db1ce0b6 100644
--- a/postgis/lwgeom_functions_basic.c
+++ b/postgis/lwgeom_functions_basic.c
@@ -1562,8 +1562,8 @@ Datum LWGEOM_makepoly(PG_FUNCTION_ARGS)
const LWLINE **holes = NULL;
LWPOLY *outpoly;
uint32 nholes = 0;
+ uint32 nitems = 0;
uint32 i;
- size_t offset = 0;
POSTGIS_DEBUG(2, "LWGEOM_makepoly called.");
@@ -1578,28 +1578,31 @@ 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));
- holes = lwalloc(sizeof(LWLINE *) * nholes);
- for (i = 0; i < nholes; i++)
+ nitems = ArrayGetNItems(ARR_NDIM(array), ARR_DIMS(array));
+ 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;
LWLINE *hole;
- offset += INTALIGN(VARSIZE(g));
+
+ if (isnull)
+ continue;
+
+ g = (GSERIALIZED *)DatumGetPointer(value);
if (gserialized_get_type(g) != LINETYPE)
{
- lwpgerror("Hole %d is not a line", i);
+ lwpgerror("Hole %d is not a line", nholes);
}
hole = lwgeom_as_lwline(lwgeom_from_gserialized(g));
- holes[i] = hole;
+ holes[nholes++] = hole;
}
+ array_free_iterator(iterator);
}
outpoly = lwpoly_from_lwlines(shell, nholes, holes);
@@ -1613,6 +1616,8 @@ Datum LWGEOM_makepoly(PG_FUNCTION_ARGS)
{
lwline_free((LWLINE *)holes[i]);
}
+ if (holes)
+ lwfree(holes);
PG_RETURN_POINTER(result);
}
diff --git a/regress/core/tickets.sql b/regress/core/tickets.sql
index c51dc87d1..b86e2a0aa 100644
--- a/regress/core/tickets.sql
+++ b/regress/core/tickets.sql
@@ -1623,3 +1623,8 @@ DROP TABLE IF EXISTS test5829, test5978;
-- #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 b7202fc70..4729b1d5e 100644
--- a/regress/core/tickets_expected
+++ b/regress/core/tickets_expected
@@ -491,3 +491,4 @@ public|test5829|geom|2|4326|GEOMETRY
public|test5978|geometry|2|4326|POINT
public|test5978|shape|2|4326|POINT
#5357|LINESTRING(38.903876 55.336448,38.903875 55.336448)
+makepolygon-null-holes|4
-----------------------------------------------------------------------
Summary of changes:
NEWS | 2 ++
postgis/lwgeom_functions_basic.c | 35 ++++++++++++++++++++---------------
regress/core/tickets.sql | 5 +++++
regress/core/tickets_expected | 1 +
4 files changed, 28 insertions(+), 15 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list