[SCM] PostGIS branch stable-3.2 updated. 3.2.6-18-g4a05e74f3

git at osgeo.org git at osgeo.org
Wed Jan 10 11:51:17 PST 2024


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.2 has been updated
       via  4a05e74f3ec34ca49c598d25edb5b4a9c2f17a0d (commit)
       via  efa50286334dd9b296f69b63c585af5fe2834a96 (commit)
      from  9f1e041ad246e3e993c6f9569850d05133fb383d (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 4a05e74f3ec34ca49c598d25edb5b4a9c2f17a0d
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Wed Jan 10 11:51:11 2024 -0800

    Crash on collections with empty members, references #5646

diff --git a/NEWS b/NEWS
index 5a9f9b748..6178b9624 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 6fa02c296..4e94f636a 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 */

commit efa50286334dd9b296f69b63c585af5fe2834a96
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Tue Jan 9 14:22:06 2024 -0800

    Fix ST_Covers mixed p-i-p case, #5647

diff --git a/NEWS b/NEWS
index b01e9fa46..5a9f9b748 100644
--- a/NEWS
+++ b/NEWS
@@ -9,7 +9,7 @@ Proj 6.1+, and PostgreSQL 14+.
 * Bug Fixes and Enhancements *
  - #5610, Regression fix: Allow Nan and infinity again
           in ST_SetPoint (Regina Obe)
- - #5627, Handling of EMPTY components in PiP check (Paul Ramsey)
+ - #5627, #5647, Handling of EMPTY components in PiP check (Paul Ramsey)
  - #5629, Handling EMPTY components in repeated point removal (Paul Ramsey)
  - #5604, Handle distance between collections with empty elements (Paul Ramsey)
  - #5635, Handle NaN points in ST_Split (Regina Obe)
diff --git a/postgis/lwgeom_geos.c b/postgis/lwgeom_geos.c
index 743efb694..a73c6aa0d 100644
--- a/postgis/lwgeom_geos.c
+++ b/postgis/lwgeom_geos.c
@@ -143,7 +143,6 @@ static int
 pip_short_circuit(RTREE_POLY_CACHE *poly_cache, LWPOINT *point, const GSERIALIZED *gpoly)
 {
 	int result;
-
 	if ( poly_cache && poly_cache->ringIndices )
 	{
         result = point_in_multipolygon_rtree(poly_cache->ringIndices, poly_cache->polyCount, poly_cache->ringCounts, point);
@@ -1817,18 +1816,20 @@ Datum contains(PG_FUNCTION_ARGS)
 		else if (gserialized_get_type(gpoint) == MULTIPOINTTYPE)
 		{
 			LWMPOINT* mpoint = lwgeom_as_lwmpoint(lwgeom_from_gserialized(gpoint));
-			uint32_t i;
 			int found_completely_inside = LW_FALSE;
 
 			retval = LW_TRUE;
-			for (i = 0; i < mpoint->ngeoms; i++)
+			for (uint32_t i = 0; i < mpoint->ngeoms; i++)
 			{
+				int pip_result;
+				LWPOINT* pt = mpoint->geoms[i];
 				/* We need to find at least one point that's completely inside the
 				 * polygons (pip_result == 1).  As long as we have one point that's
 				 * completely inside, we can have as many as we want on the boundary
 				 * itself. (pip_result == 0)
 				 */
-				int pip_result = pip_short_circuit(cache, mpoint->geoms[i], gpoly);
+				if (lwpoint_is_empty(pt)) continue;
+				pip_result = pip_short_circuit(cache, pt, gpoly);
 				if (pip_result == 1)
 					found_completely_inside = LW_TRUE;
 
@@ -2027,8 +2028,9 @@ Datum covers(PG_FUNCTION_ARGS)
 			retval = LW_TRUE;
 			for (i = 0; i < mpoint->ngeoms; i++)
 			{
-				int pip_result = pip_short_circuit(cache, mpoint->geoms[i], gpoly);
-				if (pip_result == -1)
+				LWPOINT *pt = mpoint->geoms[i];
+				if (lwpoint_is_empty(pt)) continue;
+				if (pip_short_circuit(cache, pt, gpoly) == -1)
 				{
 					retval = LW_FALSE;
 					break;
@@ -2159,8 +2161,9 @@ Datum coveredby(PG_FUNCTION_ARGS)
 			retval = LW_TRUE;
 			for (i = 0; i < mpoint->ngeoms; i++)
 			{
-				int pip_result = pip_short_circuit(cache, mpoint->geoms[i], gpoly);
-				if (pip_result == -1)
+				LWPOINT *pt = mpoint->geoms[i];
+				if (lwpoint_is_empty(pt)) continue;
+				if (pip_short_circuit(cache, pt, gpoly) == -1)
 				{
 					retval = LW_FALSE;
 					break;
@@ -2317,13 +2320,12 @@ Datum ST_Intersects(PG_FUNCTION_ARGS)
 		else if (gserialized_get_type(gpoint) == MULTIPOINTTYPE)
 		{
 			LWMPOINT* mpoint = lwgeom_as_lwmpoint(lwgeom_from_gserialized(gpoint));
-			uint32_t i;
-
 			retval = LW_FALSE;
-			for (i = 0; i < mpoint->ngeoms; i++)
+			for (uint32_t i = 0; i < mpoint->ngeoms; i++)
 			{
-				int pip_result = pip_short_circuit(cache, mpoint->geoms[i], gpoly);
-				if (pip_result != -1) /* not outside */
+				LWPOINT *pt = mpoint->geoms[i];
+				if (lwpoint_is_empty(pt)) continue;
+				if (pip_short_circuit(cache, pt, gpoly) != -1) /* not outside */
 				{
 					retval = LW_TRUE;
 					break;

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

Summary of changes:
 NEWS                                |  3 ++-
 postgis/lwgeom_functions_analytic.c |  3 +++
 postgis/lwgeom_geos.c               | 28 +++++++++++++++-------------
 3 files changed, 20 insertions(+), 14 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list