From: Sandro Santilli Date: Wed, 27 Aug 2014 08:53:30 +0000 (+0000) Subject: Fix crash on null input to ST_Union(raster) X-Git-Tag: 2.2.0rc1~873 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3fac48144ce5c42092e7b8d893ede63f3631c655;p=postgis Fix crash on null input to ST_Union(raster) git-svn-id: http://svn.osgeo.org/postgis/trunk@12925 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/raster/rt_pg/rtpg_mapalgebra.c b/raster/rt_pg/rtpg_mapalgebra.c index b486e1986..54a9cf62d 100644 --- a/raster/rt_pg/rtpg_mapalgebra.c +++ b/raster/rt_pg/rtpg_mapalgebra.c @@ -2876,6 +2876,8 @@ Datum RASTER_union_finalfn(PG_FUNCTION_ARGS) pfree(itrset); rtpg_union_arg_destroy(iwr); + if (!_rtn) PG_RETURN_NULL(); + pgraster = rt_raster_serialize(_rtn); rt_raster_destroy(_rtn); diff --git a/raster/test/regress/rt_union.sql b/raster/test/regress/rt_union.sql index 7a2e6a22f..8b47e877f 100644 --- a/raster/test/regress/rt_union.sql +++ b/raster/test/regress/rt_union.sql @@ -424,6 +424,7 @@ INSERT INTO raster_union_in SELECT 61, ST_AddBand(ST_MakeEmptyRaster(2, 2, 0, 0, 1, -1, 0, 0, 0), 1, '8BUI', 2, 0) AS rast UNION ALL SELECT 62, ST_AddBand(ST_MakeEmptyRaster(2, 2, 2, 0, 1, -1, 0, 0, 0), 1, '8BUI', 3, 0) AS rast UNION ALL SELECT 63, ST_AddBand(ST_MakeEmptyRaster(2, 2, -1, -3, 1, -1, 0, 0, 0), 1, '8BUI', 4, 0) AS rast UNION ALL + SELECT 0, NULL::raster UNION ALL -- toxic element embedded SELECT 64, ST_AddBand(ST_MakeEmptyRaster(2, 2, -2, 4, 1, -1, 0, 0, 0), 1, '8BUI', 5, 0) AS rast ; @@ -452,3 +453,7 @@ ORDER BY uniontype, y, x; DROP TABLE IF EXISTS raster_union_in; DROP TABLE IF EXISTS raster_union_out; + +-- Some toxic input +SELECT 'none', ST_Union(r) from ( select null::raster r where false ) f; +SELECT 'null', ST_Union(null::raster); diff --git a/raster/test/regress/rt_union_expected b/raster/test/regress/rt_union_expected index 4b72d9242..ac32ef69d 100644 --- a/raster/test/regress/rt_union_expected +++ b/raster/test/regress/rt_union_expected @@ -628,3 +628,5 @@ LAST|5|8|1 LAST|6|8|1 LAST|2|9|4 LAST|3|9|4 +none| +null|