From 4a05e74f3ec34ca49c598d25edb5b4a9c2f17a0d Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Wed, 10 Jan 2024 11:51:11 -0800 Subject: [PATCH] Crash on collections with empty members, references #5646 --- NEWS | 1 + postgis/lwgeom_functions_analytic.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/NEWS b/NEWS index 5a9f9b74891..6178b962440 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,7 @@ Proj 6.1+, and PostgreSQL 14+. - #5604, Handle distance between collections with empty elements (Paul Ramsey) - #5635, Handle NaN points in ST_Split (Regina Obe) - Logic error in ST_Covers(geography) (Paul Ramsey) + - #5646, Crash on collections with empty members (Paul Ramsey) PostGIS 3.2.6 diff --git a/postgis/lwgeom_functions_analytic.c b/postgis/lwgeom_functions_analytic.c index 6fa02c2963b..4e94f636a0e 100644 --- a/postgis/lwgeom_functions_analytic.c +++ b/postgis/lwgeom_functions_analytic.c @@ -947,6 +947,9 @@ int point_in_multipolygon_rtree(RTREE_NODE **root, int polyCount, int *ringCount /* is the point inside any of the sub-polygons? */ for ( p = 0; p < polyCount; p++ ) { + /* Skip empty polygons */ + if( ringCounts[p] == 0 ) continue; + in_ring = point_in_ring_rtree(root[i], &pt); POSTGIS_DEBUGF(4, "point_in_multipolygon_rtree: exterior ring (%d), point_in_ring returned %d", p, in_ring); if ( in_ring == -1 ) /* outside the exterior ring */