Skip to content

Commit

Permalink
avoid segfault on erroneous mask references (#4779)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbonfort committed Oct 4, 2013
1 parent 942e1d7 commit 8a32f71
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions mapresample.c
Original file line number Diff line number Diff line change
Expand Up @@ -1253,12 +1253,19 @@ int msResampleGDALToMap( mapObj *map, layerObj *layer, imageObj *image,
resampleMode = "NEAREST";

if(layer->mask) {
int ret;
layerObj *maskLayer = GET_LAYER(map, msGetLayerIndex(map,layer->mask));
int ret, maskLayerIdx;
maskLayerIdx = msGetLayerIndex(map,layer->mask);
if(maskLayerIdx == -1) {
msSetError(MS_MISCERR, "Invalid mask layer specified", "msResampleGDALToMap()");
return -1;
}
layerObj *maskLayer = GET_LAYER(map, maskLayerIdx);
mask_rb = msSmallCalloc(1,sizeof(rasterBufferObj));
ret = MS_IMAGE_RENDERER(maskLayer->maskimage)->getRasterBufferHandle(maskLayer->maskimage,mask_rb);
if(ret != MS_SUCCESS)
if(ret != MS_SUCCESS) {
free(mask_rb);
return -1;
}
}

/* -------------------------------------------------------------------- */
Expand Down

0 comments on commit 8a32f71

Please sign in to comment.