Commit 3383dff4 authored by Regina Obe's avatar Regina Obe

Fix crasher in raster when fed an empty raster (note was tempted to change the...

Fix crasher in raster when fed an empty raster (note was tempted to change the def of empty raster to include raster with no bands but not sure where else that is used, so just revised the clip check to not try to clip if no bands).
References #3055 for PostGIS 2.5 (trunk), 
also minor doc fix references #2925 for PostGIS 2.5 (trunk) 

git-svn-id: http://svn.osgeo.org/postgis/trunk@16503 b70326c6-7e19-0410-871a-916f4a2858ee
parent 02924bed
Pipeline #19618890 passed with stage
in 24 minutes and 31 seconds
This diff is collapsed.
......@@ -3022,8 +3022,8 @@ Datum RASTER_clip(PG_FUNCTION_ARGS)
}
/* raster is empty, return empty raster */
if (rt_raster_is_empty(arg->raster)) {
elog(NOTICE, "Input raster is empty. Returning empty raster");
if (rt_raster_is_empty(arg->raster) || rt_raster_get_num_bands(arg->raster) == 0) {
elog(NOTICE, "Input raster is empty or has no bands. Returning empty raster");
rtpg_clip_arg_destroy(arg);
PG_FREE_IF_COPY(pgraster, 0);
......
......@@ -112,3 +112,8 @@ DROP TABLE IF EXISTS test_raster_scale_big;
DROP TABLE IF EXISTS test_raster_scale_small;
SET client_min_messages TO DEFAULT;
/******************************************************************************
#3055 ST_Clip() on a raster without band crashes the server
******************************************************************************/
SELECT ST_SummaryStats(ST_Clip(ST_MakeEmptyRaster(42, 42, 0, 0, 1.0, 1.0, 0, 0, 4269), ST_MakeEnvelope(0, 0, 20, 20, 4269)));
......@@ -12,3 +12,5 @@ ERROR: new row for relation "test_raster_scale_big" violates check constraint "
t
test_raster_scale_small|rast||1
ERROR: new row for relation "test_raster_scale_small" violates check constraint "enforce_scaley_rast"
NOTICE: Input raster is empty or has no bands. Returning empty raster
NOTICE: Invalid band index (must use 1-based). Returning NULL
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment