Skip to content
Permalink
Browse files
Add sanity checks to avoid segfaults in Mapscript pointObj::draw()
  • Loading branch information
bragef committed Dec 19, 2019
1 parent b0c3a29 commit 8ff7bb2af85dbaec2e7490587e48dc4562a84107
Showing 1 changed file with 19 additions and 7 deletions.
@@ -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) {

0 comments on commit 8ff7bb2

Please sign in to comment.