[PostGIS] #6048: postgis_raster crashes in rt_band_set_pixel due to NULL band pointer during ST_Clip operation

PostGIS trac at osgeo.org
Tue Feb 10 03:36:45 PST 2026


#6048: postgis_raster crashes in rt_band_set_pixel due to NULL band pointer during
ST_Clip operation
--------------------+---------------------------
 Reporter:  maxmli  |      Owner:  robe
     Type:  defect  |     Status:  new
 Priority:  medium  |  Milestone:  PostGIS 3.7.0
Component:  raster  |    Version:  3.6.x
 Keywords:          |
--------------------+---------------------------
 The postgis_raster extension crashes with a segmentation fault in the
 `rt_band_set_pixel` function when executing certain `_st_clip` operations.
 The crash occurs because a NULL band pointer is passed to
 `rt_band_set_pixel`.

 '''Steps to Reproduce:'''

 {{{#!sql
 CREATE EXTENSION postgis;
 CREATE EXTENSION postgis_raster;

 WITH test_rast AS (
     SELECT
         ST_AddBand(
             ST_AddBand(
                 ST_AddBand(
                     ST_SetSRID(
                         ST_MakeEmptyRaster(10, 10, 1, 1, 1, -1, 0, 0),
 4326
                     ),
                     '8BUI'::text, 1, 0
                 ),
                 '8BUI'::text, 1, 0
             ),
             '8BUI'::text, 1, 0
         ) AS rast
 ),
 test_geom AS (
     SELECT ST_SetSRID(
         ST_MakeEnvelope(1, 1, 5, 5), 4326) AS geom
 )
 SELECT ST_Metadata(_st_clip(r.rast, ARRAY[3], g.geom, ARRAY[255, 255,
 255], FALSE))
 FROM test_rast r, test_geom g;
 }}}

 '''Stack Trace:'''
 {{{
 #0  rt_band_set_pixel (band=band at entry=0x0, x=x at entry=0, y=y at entry=0,
 val=1, converted=converted at entry=0x0) at rt_band.c:1160
 #1  0x00007f938f940b68 in RASTER_clip (fcinfo=<optimized out>) at
 rtpg_mapalgebra.c:3437
 #2  0x00000000006a0553 in ExecInterpExpr (state=0xde46860,
 econtext=0xde46f68, isnull=0x7ffcfc9deeef) at execExprInterp.c:931
 #3  0x00000000006a28d2 in ExecInterpExprStillValid (state=0xde46860,
 econtext=0xde46f68, isNull=0x7ffcfc9deeef) at execExprInterp.c:2311
 #4  0x000000000082c007 in ExecEvalExprSwitchContext (state=0xde46860,
 econtext=0xde46f68, isNull=0x7ffcfc9deeef)
     at ../../../../src/include/executor/executor.h:440
 #5  0x0000000000833498 in evaluate_expr (expr=0xde4c420,
 result_type=53657, result_typmod=-1, result_collation=0) at clauses.c:5014
 #6  0x000000000083281e in evaluate_function (funcid=54127,
 result_type=53657, result_typmod=-1, result_collid=0, input_collid=0,
     args=0xde4b528, funcvariadic=false, func_tuple=0x7f9391781f58,
 context=0x7ffcfc9e0d10) at clauses.c:4521
 #7  0x0000000000831d13 in simplify_function (funcid=54127,
 result_type=53657, result_typmod=-1, result_collid=0, input_collid=0,
     args_p=0x7ffcfc9df100, funcvariadic=false, process_args=true,
 allow_non_const=true, context=0x7ffcfc9e0d10) at clauses.c:4110
 #8  0x000000000082f367 in eval_const_expressions_mutator (node=0xde43e68,
 context=0x7ffcfc9e0d10) at clauses.c:2595
 }}}
-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/6048>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-tickets mailing list