[postgis-tickets] r17174 - Avoid passing a NULL pointer to GEOSisEmpty
Raul
raul at rmr.ninja
Fri Jan 18 08:05:18 PST 2019
Author: algunenano
Date: 2019-01-18 08:05:18 -0800 (Fri, 18 Jan 2019)
New Revision: 17174
Modified:
trunk/NEWS
trunk/liblwgeom/lwgeom_geos_clean.c
trunk/liblwgeom/lwgeom_geos_cluster.c
Log:
Avoid passing a NULL pointer to GEOSisEmpty
References #4275
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2019-01-18 11:58:46 UTC (rev 17173)
+++ trunk/NEWS 2019-01-18 16:05:18 UTC (rev 17174)
@@ -66,6 +66,7 @@
- #4301, ST_Subdivide: fix endless loop on coordinates near coincident to bounds
(Darafei Praliaskouski)
- #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.0
Modified: trunk/liblwgeom/lwgeom_geos_clean.c
===================================================================
--- trunk/liblwgeom/lwgeom_geos_clean.c 2019-01-18 11:58:46 UTC (rev 17173)
+++ trunk/liblwgeom/lwgeom_geos_clean.c 2019-01-18 16:05:18 UTC (rev 17174)
@@ -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: trunk/liblwgeom/lwgeom_geos_cluster.c
===================================================================
--- trunk/liblwgeom/lwgeom_geos_cluster.c 2019-01-18 11:58:46 UTC (rev 17173)
+++ trunk/liblwgeom/lwgeom_geos_cluster.c 2019-01-18 16:05:18 UTC (rev 17174)
@@ -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