Permalink
Browse files

Ensure class labels are free'd in cases where label loading fails

  • Loading branch information...
1 parent ef10744 commit bb9d6df783f8de552d485054b285ace97c26be65 @homme homme committed Jul 4, 2013
Showing with 5 additions and 1 deletion.
  1. +5 −1 mapfile.c
View
@@ -1867,6 +1867,7 @@ static int loadLabel(labelObj *label)
break;
case(EOF):
msSetError(MS_EOFERR, NULL, "loadLabel()");
+ freeLabel(label); /* free any structures allocated before EOF */
return(-1);
case(EXPRESSION):
if(loadExpression(&(label->expression)) == -1) return(-1); /* loadExpression() cleans up previously allocated expression */
@@ -3482,7 +3483,10 @@ int loadClass(classObj *class, layerObj *layer)
if(msGrowClassLabels(class) == NULL) return(-1);
initLabel(class->labels[class->numlabels]);
class->labels[class->numlabels]->size = MS_MEDIUM; /* only set a default if the LABEL section is present */
- if(loadLabel(class->labels[class->numlabels]) == -1) return(-1);
+ if(loadLabel(class->labels[class->numlabels]) == -1) {
+ msFree(class->labels[class->numlabels]);
+ return(-1);
+ }
class->numlabels++;
break;
case(LEADER):

0 comments on commit bb9d6df

Please sign in to comment.