mapserver/mapserver — pull request #4779 by tbonfort (2013-10-04 09:34:01+00:00)
Title: segfault on uvraster with mask in 6.4.0

Regards,

I am experiencing segfaults on a uvraster layer when I enable a mask. The same mask works properly on a different layer, and used to work perfectly on 6.2.0 and 6.2.1.

A simplified testcase with the required map and data files is available in https://www.dropbox.com/sh/608ggyyd5oli3ir/3PbxdtXFAr

With shp2img:

```
(gdb) run -m ~qrms/wms/testcase/testcase.map
Starting program: /root/src/mapserver/mapserver-6.4.0/build/shp2img -m ~qrms/wms/testcase/testcase.map
[Thread debugging using libthread_db enabled]

Program received signal SIGSEGV, Segmentation fault.
msResampleGDALToMap (map=0x64e870, layer=0x61a920, image=0x64b380, rb=, hDS=0x7bcb90)
at /root/src/mapserver/mapserver-6.4.0/mapresample.c:1257
1257	layerObj *maskLayer = GET_LAYER(map, msGetLayerIndex(map,layer->mask));
(gdb) bt
#0 msResampleGDALToMap (map=0x64e870, layer=0x61a920, image=0x64b380, rb=, hDS=0x7bcb90)
at /root/src/mapserver/mapserver-6.4.0/mapresample.c:1257
#1 0x00007ffff7acfce9 in msDrawRasterLayerLow (map=0x64e870, layer=0x61a920, image=,
rb=) at /root/src/mapserver/mapserver-6.4.0/mapraster.c:855
#2 0x00007ffff7ad17e2 in msUVRASTERLayerWhichShapes (layer=0x61a920, rect=..., isQuery=)
at /root/src/mapserver/mapserver-6.4.0/mapuvraster.c:449
#3 0x00007ffff7ab95c0 in msDrawVectorLayer (map=0x60fe20, layer=0x61a920, image=0x64bd70)
at /root/src/mapserver/mapserver-6.4.0/mapdraw.c:961
#4 0x00007ffff7abaa98 in msDrawLayer (map=0x60fe20, layer=0x61a920, image=0x642dd0)
at /root/src/mapserver/mapserver-6.4.0/mapdraw.c:810
#5 0x00007ffff7abbebe in msDrawMap (map=0x60fe20, querymap=)
at /root/src/mapserver/mapserver-6.4.0/mapdraw.c:436
#6 0x0000000000401a60 in main (argc=3, argv=)
at /root/src/mapserver/mapserver-6.4.0/shp2img.c:293
(gdb) print map->layers
$1 = (layerObj **) 0x0
(gdb) print layer->mask
$2 = 0x617a10 "ocean"
```
I believe the whole uvraster might be initializing wrong, as if I comment out the mask the image comes out properly, but breaking on mapresample.c:1255 results in map->layers being a null pointer as well.

My build is a custom squeeze amd64 backport with JAVA enabled based on the debian GIS package, but I have verified a crash (however I don't have debugging enabled) in my local fink 6.4.0 build in OSX 10.8.