Commit f32b7827 authored by Bborie Park's avatar Bborie Park

Fix ST_DumpValues() crasher when cleaning. Ticket #3086

git-svn-id: http://svn.osgeo.org/postgis/trunk@13390 b70326c6-7e19-0410-871a-916f4a2858ee
parent c2c40adf
......@@ -91,7 +91,8 @@ PostGIS 2.2.0
max extent constraint
- #3020, ST_AddBand out-db bug where height using width value
- #3061, Allow duplicate points in JSON, GML, GML ST_GeomFrom* functions
- #3086, ST_DumpValues() crashes backend on cleanup with invalid
band indexes
* Code refactoring *
......
......@@ -174,20 +174,23 @@ static rtpg_dumpvalues_arg rtpg_dumpvalues_arg_init() {
static void rtpg_dumpvalues_arg_destroy(rtpg_dumpvalues_arg arg) {
int i = 0;
if (arg->numbands) {
if (arg->numbands > 0) {
if (arg->nbands != NULL)
pfree(arg->nbands);
for (i = 0; i < arg->numbands; i++) {
if (arg->values[i] != NULL)
pfree(arg->values[i]);
if (arg->values != NULL) {
for (i = 0; i < arg->numbands; i++) {
if (arg->nodata[i] != NULL)
pfree(arg->nodata[i]);
}
if (arg->values[i] != NULL)
pfree(arg->values[i]);
if (arg->nodata[i] != NULL)
pfree(arg->nodata[i]);
}
if (arg->values != NULL)
pfree(arg->values);
}
if (arg->nodata != NULL)
pfree(arg->nodata);
}
......@@ -363,6 +366,7 @@ Datum RASTER_dumpValues(PG_FUNCTION_ARGS)
}
}
/* no bands specified, return all bands */
else {
arg1->numbands = numbands;
arg1->nbands = palloc(sizeof(int) * arg1->numbands);
......
......@@ -98,4 +98,16 @@ ORDER BY rid;
DROP TABLE IF EXISTS raster_dumpvalues;
SELECT (ST_DumpValues(ST_AddBand(ST_MakeEmptyRaster(0, 0, 0, 0, 1), ARRAY[ROW(NULL, '8BUI', 255, 0),ROW(NULL, '16BUI', 1, 2)]::addbandarg[]))).*
SELECT (ST_DumpValues(ST_AddBand(ST_MakeEmptyRaster(0, 0, 0, 0, 1), ARRAY[ROW(NULL, '8BUI', 255, 0),ROW(NULL, '16BUI', 1, 2)]::addbandarg[]))).*;
-- #3086
DROP TABLE IF EXISTS raster_tile;
CREATE TABLE raster_tile AS
WITH foo AS (
SELECT ST_AddBand(ST_AddBand(ST_MakeEmptyRaster(3, 3, 0, 0, 1, -1, 0, 0, 0), 1, '8BUI', 1, 0), 2, '8BUI', 10, 0) AS rast UNION ALL
SELECT ST_AddBand(ST_AddBand(ST_MakeEmptyRaster(3, 3, 3, 0, 1, -1, 0, 0, 0), 1, '8BUI', 2, 0), 2, '8BUI', 20, 0) AS rast
)
SELECT ST_Union(rast) AS rast FROM foo;
WITH foo AS (SELECT ST_Tile(rast, 3, 3, TRUE) AS rast FROM raster_tile) SELECT (ST_DumpValues(rast, array[1,2,3])).* FROM foo;
DROP TABLE IF EXISTS raster_tile;
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