[postgis-tickets] r17175 - Avoid passing a NULL pointer to GEOSisEmpty

Raul raul at rmr.ninja
Fri Jan 18 08:06:15 PST 2019


Author: algunenano
Date: 2019-01-18 08:06:14 -0800 (Fri, 18 Jan 2019)
New Revision: 17175

Modified:
   branches/2.5/NEWS
   branches/2.5/liblwgeom/lwgeom_geos_clean.c
   branches/2.5/liblwgeom/lwgeom_geos_cluster.c
Log:
Avoid passing a NULL pointer to GEOSisEmpty

References #4275


Modified: branches/2.5/NEWS
===================================================================
--- branches/2.5/NEWS	2019-01-18 16:05:18 UTC (rev 17174)
+++ branches/2.5/NEWS	2019-01-18 16:06:14 UTC (rev 17175)
@@ -38,6 +38,7 @@
 
   - #4289, ST_AsMVTGeom: Transform coordinates space before clipping (Raúl Marín)
 
+  - #4275, Avoid passing a NULL pointer to GEOSisEmpty (Raúl Marín)
 
 PostGIS 2.5.1
 2018/11/18

Modified: branches/2.5/liblwgeom/lwgeom_geos_clean.c
===================================================================
--- branches/2.5/liblwgeom/lwgeom_geos_clean.c	2019-01-18 16:05:18 UTC (rev 17174)
+++ branches/2.5/liblwgeom/lwgeom_geos_clean.c	2019-01-18 16:06:14 UTC (rev 17175)
@@ -573,11 +573,15 @@
 		const GEOSGeometry* g = GEOSGetGeometryN(gin, i);
 		GEOSGeometry* vg;
 		vg = LWGEOM_GEOS_makeValidLine(g);
+		/* Drop any invalid or empty geometry */
+		if (!vg)
+			continue;
 		if (GEOSisEmpty(vg))
 		{
-			/* we don't care about this one */
 			GEOSGeom_destroy(vg);
+			continue;
 		}
+
 		if (GEOSGeomTypeId(vg) == GEOS_POINT)
 			points[npoints++] = vg;
 		else if (GEOSGeomTypeId(vg) == GEOS_LINESTRING)
@@ -827,7 +831,7 @@
 		pd = GEOSDifference(pi, po); /* input points - output points */
 		GEOSGeom_destroy(pi);
 		GEOSGeom_destroy(po);
-		loss = !GEOSisEmpty(pd);
+		loss = pd && !GEOSisEmpty(pd);
 		GEOSGeom_destroy(pd);
 		if (loss)
 		{

Modified: branches/2.5/liblwgeom/lwgeom_geos_cluster.c
===================================================================
--- branches/2.5/liblwgeom/lwgeom_geos_cluster.c	2019-01-18 16:05:18 UTC (rev 17174)
+++ branches/2.5/liblwgeom/lwgeom_geos_cluster.c	2019-01-18 16:06:14 UTC (rev 17175)
@@ -178,7 +178,7 @@
 	{
 		const GEOSPreparedGeometry* prep = NULL;
 
-		if (GEOSisEmpty(geoms[p]))
+		if (!geoms[p] || GEOSisEmpty(geoms[p]))
 			continue;
 
 		cxt.num_items_found = 0;



More information about the postgis-tickets mailing list