From: Paul Ramsey Date: Mon, 7 Apr 2014 14:44:44 +0000 (+0000) Subject: #2704, ST_DumpPoints of EMPTY geometries crashes server X-Git-Tag: 2.2.0rc1~1152 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=25784e81581c03d1bc6c27a63d26047d465aa60c;p=postgis #2704, ST_DumpPoints of EMPTY geometries crashes server git-svn-id: http://svn.osgeo.org/postgis/trunk@12430 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/NEWS b/NEWS index b914c3131..f98b0a842 100644 --- a/NEWS +++ b/NEWS @@ -58,6 +58,7 @@ PostGIS 2.2.0 - #2556, geography ST_Intersects results depending on insert order - #2634, regression in sphere distance code - #2697, invalid GeoJSON Polygon input crashes server process + - #2704, ST_DumpPoints of EMPTY geometries crashes server * Code refactoring * diff --git a/postgis/lwgeom_dumppoints.c b/postgis/lwgeom_dumppoints.c index 17fb2c601..c26d514c8 100644 --- a/postgis/lwgeom_dumppoints.c +++ b/postgis/lwgeom_dumppoints.c @@ -74,6 +74,7 @@ Datum LWGEOM_dumppoints(PG_FUNCTION_ARGS) { /* return early if nothing to do */ if (!lwgeom || lwgeom_is_empty(lwgeom)) { + MemoryContextSwitchTo(oldcontext); funcctx = SRF_PERCALL_SETUP(); SRF_RETURN_DONE(funcctx); } diff --git a/regress/dumppoints.sql b/regress/dumppoints.sql index 8ad24ded1..8e6fa540e 100644 --- a/regress/dumppoints.sql +++ b/regress/dumppoints.sql @@ -177,3 +177,9 @@ FROM ( SELECT 'CURVEPOLYGON(CIRCULARSTRING(0 0, 4 0, 4 4, 0 4, 0 0),(1 1, 3 3, 3 1, 1 1))'::geometry as geom ) as g ) j; + +SELECT '#2704', ST_DumpPoints('POLYGON EMPTY'::geometry); +SELECT '#2704', ST_DumpPoints('MULTIPOLYGON EMPTY'::geometry); +SELECT '#2704', ST_DumpPoints('MULTILINESTRING EMPTY'::geometry); +SELECT '#2704', ST_DumpPoints('LINESTRING EMPTY'::geometry); +SELECT '#2704', ST_DumpPoints('GEOMETRYCOLLECTION EMPTY'::geometry);