Skip to content

Commit

Permalink
Add sanity checks to avoid segfaults in Mapscript pointObj::draw()
Browse files Browse the repository at this point in the history
  • Loading branch information
bragef committed Dec 19, 2019
1 parent b0c3a29 commit 8ff7bb2
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions mapdraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -2240,16 +2240,28 @@ int msDrawShape(mapObj *map, layerObj *layer, shapeObj *shape, imageObj *image,
int msDrawPoint(mapObj *map, layerObj *layer, pointObj *point, imageObj *image, int classindex, char *labeltext)
{
int s,ret;
classObj *theclass=layer->class[classindex];
classObj *theclass=NULL;
labelObj *label=NULL;

if(layer->transform == MS_TRUE && layer->project)
msProjectPoint(&layer->projection, &map->projection, point);

if(labeltext && theclass->numlabels > 0) {
label = theclass->labels[0];
if(layer->transform == MS_TRUE && layer->project && msProjectionsDiffer(&(layer->projection), &(map->projection))) {
msProjectPoint(&(layer->projection), &(map->projection), point);
}


if(classindex > layer->numclasses) {
msSetError(MS_MISCERR, "Invalid classindex (%d)", "msDrawPoint()", classindex);
return MS_FAILURE;
}
theclass = layer->class[classindex];

if(labeltext) {
if(theclass->numlabels > 0) {
label = theclass->labels[0];
} else {
msSetError(MS_MISCERR, "Label missing for layer: %s", "msDrawPoint()", layer->name);
return MS_FAILURE;
}
}

switch(layer->type) {
case MS_LAYER_POINT:
if(layer->transform == MS_TRUE) {
Expand Down

0 comments on commit 8ff7bb2

Please sign in to comment.