[postgis-tickets] r16505 - 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).
Regina Obe
lr at pcorp.us
Wed Mar 28 02:02:05 PDT 2018
Author: robe
Date: 2018-03-28 02:02:04 -0700 (Wed, 28 Mar 2018)
New Revision: 16505
Modified:
branches/2.3/NEWS
branches/2.3/doc/reference_raster.xml
branches/2.3/raster/rt_pg/rtpg_mapalgebra.c
branches/2.3/raster/test/regress/tickets.sql
branches/2.3/raster/test/regress/tickets_expected
Log:
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.3.7,
also minor doc fix references #2925 for PostGIS 2.3.7
reorder NEWS tickets numerically
Modified: branches/2.3/NEWS
===================================================================
--- branches/2.3/NEWS 2018-03-28 08:53:19 UTC (rev 16504)
+++ branches/2.3/NEWS 2018-03-28 09:02:04 UTC (rev 16505)
@@ -3,13 +3,15 @@
* Bug Fixes and Enhancements
+ - #3055, [raster] ST_Clip() on a raster without band crashes the server
+ (Regina Obe)
- #3978, Fix KNN when upgrading from 2.1 or older (Sandro Santilli)
- #4003, lwpoly_construct_circle: Avoid division by zero (Raúl Marín Rodríguez)
+ - #4017, lwgeom lexer memory corruption (Peter E)
- #4020, Casting from box3d to geometry now returns correctly connected
PolyhedralSurface (Matthias Bay)
- #4025, #4032 Incorrect answers for temporally "almost overlapping" ranges
(Paul Ramsey, Darafei Praliaskouski)
- - #4017, lwgeom lexer memory corruption (Peter E)
- #4052, schema qualify several functions in geography
Modified: branches/2.3/doc/reference_raster.xml
===================================================================
--- branches/2.3/doc/reference_raster.xml 2018-03-28 08:53:19 UTC (rev 16504)
+++ branches/2.3/doc/reference_raster.xml 2018-03-28 09:02:04 UTC (rev 16505)
@@ -1808,7 +1808,7 @@
</informalfigure></para>
<programlisting>
-- this will output a black circle taking up 150 x 150 pixels --
-SELECT ST_AsPNG(ST_AsRaster(ST_Buffer(ST_Point(1,5),10),150, 150, '2BUI'));</programlisting>
+SELECT ST_AsPNG(ST_AsRaster(ST_Buffer(ST_Point(1,5),10),150, 150));</programlisting>
<para><informalfigure>
<mediaobject>
Modified: branches/2.3/raster/rt_pg/rtpg_mapalgebra.c
===================================================================
--- branches/2.3/raster/rt_pg/rtpg_mapalgebra.c 2018-03-28 08:53:19 UTC (rev 16504)
+++ branches/2.3/raster/rt_pg/rtpg_mapalgebra.c 2018-03-28 09:02:04 UTC (rev 16505)
@@ -3025,8 +3025,8 @@
}
/* 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);
Modified: branches/2.3/raster/test/regress/tickets.sql
===================================================================
--- branches/2.3/raster/test/regress/tickets.sql 2018-03-28 08:53:19 UTC (rev 16504)
+++ branches/2.3/raster/test/regress/tickets.sql 2018-03-28 09:02:04 UTC (rev 16505)
@@ -112,3 +112,8 @@
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)));
Modified: branches/2.3/raster/test/regress/tickets_expected
===================================================================
--- branches/2.3/raster/test/regress/tickets_expected 2018-03-28 08:53:19 UTC (rev 16504)
+++ branches/2.3/raster/test/regress/tickets_expected 2018-03-28 09:02:04 UTC (rev 16505)
@@ -12,3 +12,5 @@
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
More information about the postgis-tickets
mailing list