[SCM] PostGIS branch master updated. 3.4.0rc1-826-g89b31d970

git at osgeo.org git at osgeo.org
Fri Dec 1 08:08:27 PST 2023


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  89b31d970de2975320c4a4b76c9dd5a0760b51d8 (commit)
      from  8b2c090a88788bfc9dc266200fefe33de50b5c98 (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 89b31d970de2975320c4a4b76c9dd5a0760b51d8
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Fri Dec 1 08:08:15 2023 -0800

    Fix crash on multipoint repeated point with empty, #5629

diff --git a/liblwgeom/lwgeom.c b/liblwgeom/lwgeom.c
index 6f2eb9764..6a1ec79cd 100644
--- a/liblwgeom/lwgeom.c
+++ b/liblwgeom/lwgeom.c
@@ -1575,7 +1575,12 @@ cmp_point_x(const void *pa, const void *pb)
 	const POINT2D *pt1 = getPoint2d_cp(p1->point, 0);
 	const POINT2D *pt2 = getPoint2d_cp(p2->point, 0);
 
-	return (pt1->x > pt2->x) ? 1 : ((pt1->x < pt2->x) ? -1 : 0);
+	if (pt1 && pt2)
+		return (pt1->x > pt2->x) ? 1 : ((pt1->x < pt2->x) ? -1 : 0);
+
+	if (pt1) return -1;
+	if (pt2) return 1;
+	return 0;
 }
 
 static int
@@ -1587,7 +1592,12 @@ cmp_point_y(const void *pa, const void *pb)
 	const POINT2D *pt1 = getPoint2d_cp(p1->point, 0);
 	const POINT2D *pt2 = getPoint2d_cp(p2->point, 0);
 
-	return (pt1->y > pt2->y) ? 1 : ((pt1->y < pt2->y) ? -1 : 0);
+	if (pt1 && pt2)
+		return (pt1->y > pt2->y) ? 1 : ((pt1->y < pt2->y) ? -1 : 0);
+
+	if (pt1) return -1;
+	if (pt2) return 1;
+	return 0;
 }
 
 int
@@ -1650,6 +1660,7 @@ lwgeom_remove_repeated_points_in_place(LWGEOM *geom, double tolerance)
 					continue;
 
 				const POINT2D *pti = getPoint2d_cp(mpt->geoms[i]->point, 0);
+				if (!pti) continue;
 
 				/* check upcoming points if they're within tolerance of current one */
 				for (uint32_t j = i + 1; j < mpt->ngeoms; j++)
@@ -1658,6 +1669,7 @@ lwgeom_remove_repeated_points_in_place(LWGEOM *geom, double tolerance)
 						continue;
 
 					const POINT2D *ptj = getPoint2d_cp(mpt->geoms[j]->point, 0);
+					if (!ptj) continue;
 
 					/* check that the point is in the strip of tolerance around the point */
 					if ((dim ? ptj->x - pti->x : ptj->y - pti->y) > tolerance)
@@ -1673,6 +1685,17 @@ lwgeom_remove_repeated_points_in_place(LWGEOM *geom, double tolerance)
 				}
 			}
 
+			/* null out empties */
+			for (uint32_t j = 0; j < mpt->ngeoms; j++)
+			{
+				if (mpt->geoms[j] && lwpoint_is_empty(mpt->geoms[j]))
+				{
+					lwpoint_free(mpt->geoms[j]);
+					mpt->geoms[j] = NULL;
+					geometry_modified = LW_TRUE;
+				}
+			}
+
 			/* compactify array of points */
 			uint32_t i = 0;
 			for (uint32_t j = 0; j < mpt->ngeoms; j++)

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

Summary of changes:
 liblwgeom/lwgeom.c | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list