From: Daniel Baston Date: Wed, 4 May 2016 00:56:52 +0000 (+0000) Subject: #3470, ST_Polygonize doesn't accept NULL geometries X-Git-Tag: 2.3.0beta1~128 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5ccf7719f715fd5338622bd02ad96800f9751555;p=postgis #3470, ST_Polygonize doesn't accept NULL geometries git-svn-id: http://svn.osgeo.org/postgis/trunk@14882 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/lwgeom_accum.c b/postgis/lwgeom_accum.c index 3eb5a98b6..951c51a59 100644 --- a/postgis/lwgeom_accum.c +++ b/postgis/lwgeom_accum.c @@ -289,7 +289,9 @@ pgis_geometry_polygonize_finalfn(PG_FUNCTION_ARGS) p = (pgis_abs*) PG_GETARG_POINTER(0); geometry_array = pgis_accum_finalfn(p, CurrentMemoryContext, fcinfo); - result = DirectFunctionCall1( polygonize_garray, geometry_array ); + result = PGISDirectFunctionCall1( polygonize_garray, geometry_array ); + if (!result) + PG_RETURN_NULL(); PG_RETURN_DATUM(result); } diff --git a/postgis/lwgeom_geos.c b/postgis/lwgeom_geos.c index a87fda923..8018cc926 100644 --- a/postgis/lwgeom_geos.c +++ b/postgis/lwgeom_geos.c @@ -3060,7 +3060,6 @@ Datum GEOSnoop(PG_FUNCTION_ARGS) PG_FUNCTION_INFO_V1(polygonize_garray); Datum polygonize_garray(PG_FUNCTION_ARGS) { - Datum datum; ArrayType *array; int is3d = 0; uint32 nelems, i; @@ -3068,7 +3067,6 @@ Datum polygonize_garray(PG_FUNCTION_ARGS) GEOSGeometry *geos_result; const GEOSGeometry **vgeoms; int srid=SRID_UNKNOWN; - size_t offset; #if POSTGIS_DEBUG_LEVEL >= 3 static int call=1; #endif @@ -3077,47 +3075,21 @@ Datum polygonize_garray(PG_FUNCTION_ARGS) call++; #endif - datum = PG_GETARG_DATUM(0); - - /* Null array, null geometry (should be empty?) */ - if ( (Pointer *)datum == NULL ) PG_RETURN_NULL(); - - array = DatumGetArrayTypeP(datum); + if (PG_ARGISNULL(0)) + PG_RETURN_NULL(); - nelems = ArrayGetNItems(ARR_NDIM(array), ARR_DIMS(array)); + array = PG_GETARG_ARRAYTYPE_P(0); + nelems = array_nelems_not_null(array); - POSTGIS_DEBUGF(3, "polygonize_garray: number of elements: %d", nelems); + if (nelems == 0) + PG_RETURN_NULL(); - if ( nelems == 0 ) PG_RETURN_NULL(); + POSTGIS_DEBUGF(3, "polygonize_garray: number of non-null elements: %d", nelems); /* Ok, we really need geos now ;) */ initGEOS(lwpgnotice, lwgeom_geos_error); - vgeoms = palloc(sizeof(GEOSGeometry *)*nelems); - offset = 0; - for (i=0; i