[mapserver-commits] r8520 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Mon Feb 9 12:16:12 EST 2009
Author: aboudreault
Date: 2009-02-09 12:16:11 -0500 (Mon, 09 Feb 2009)
New Revision: 8520
Modified:
trunk/mapserver/HISTORY.TXT
trunk/mapserver/mapfile.c
Log:
Fixed memory leaks when using msUpdate*FromString methods. (#2857)
Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT 2009-02-09 16:58:44 UTC (rev 8519)
+++ trunk/mapserver/HISTORY.TXT 2009-02-09 17:16:11 UTC (rev 8520)
@@ -12,6 +12,8 @@
Current Version (5.3-dev, SVN trunk):
------------------------------------
+- Fixed memory leaks when using msUpdate*FromString methods. (#2857)
+
- Fixed the problem when removing the attribute binding in mapscript.
- SOS XML validity fixes (#2646)
Modified: trunk/mapserver/mapfile.c
===================================================================
--- trunk/mapserver/mapfile.c 2009-02-09 16:58:44 UTC (rev 8519)
+++ trunk/mapserver/mapfile.c 2009-02-09 17:16:11 UTC (rev 8520)
@@ -1269,6 +1269,8 @@
if(symbol == MS_NUMBER)
label->angle = msyynumber;
else if(symbol == MS_BINDING) {
+ if (label->bindings[MS_LABEL_BINDING_ANGLE].item != NULL)
+ msFree(label->bindings[MS_LABEL_BINDING_ANGLE].item);
label->bindings[MS_LABEL_BINDING_ANGLE].item = strdup(msyytext);
label->numbindings++;
} else if ( symbol == MS_FOLLOW ) {
@@ -1326,8 +1328,12 @@
return(-1);
if(symbol == MS_STRING) {
+ if (label->font != NULL)
+ msFree(label->font);
label->font = strdup(msyytext);
} else {
+ if (label->bindings[MS_LABEL_BINDING_FONT].item != NULL)
+ msFree(label->bindings[MS_LABEL_BINDING_FONT].item);
label->bindings[MS_LABEL_BINDING_FONT].item = strdup(msyytext);
label->numbindings++;
}
@@ -1400,7 +1406,9 @@
return(-1);
}
} else {
- label->bindings[MS_LABEL_BINDING_PRIORITY].item = strdup(msyytext);
+ if (label->bindings[MS_LABEL_BINDING_PRIORITY].item != NULL)
+ msFree(label->bindings[MS_LABEL_BINDING_PRIORITY].item);
+ label->bindings[MS_LABEL_BINDING_PRIORITY].item = strdup(msyytext);
label->numbindings++;
}
break;
@@ -1424,6 +1432,8 @@
if(symbol == MS_NUMBER) {
label->size = (double) msyynumber;
} else if(symbol == MS_BINDING) {
+ if (label->bindings[MS_LABEL_BINDING_SIZE].item != NULL)
+ msFree(label->bindings[MS_LABEL_BINDING_SIZE].item);
label->bindings[MS_LABEL_BINDING_SIZE].item = strdup(msyytext);
label->numbindings++;
} else
@@ -1578,6 +1588,8 @@
int loadExpression(expressionObj *exp)
{
if((exp->type = getSymbol(5, MS_STRING,MS_EXPRESSION,MS_REGEX,MS_ISTRING,MS_IREGEX)) == -1) return(-1);
+ if (exp->string != NULL)
+ msFree(exp->string);
exp->string = strdup(msyytext);
if(exp->type == MS_ISTRING)
@@ -1844,6 +1856,8 @@
if(symbol == MS_NUMBER)
style->angle = (double) msyynumber;
else if(symbol==MS_BINDING){
+ if (style->bindings[MS_STYLE_BINDING_ANGLE].item != NULL)
+ msFree(style->bindings[MS_STYLE_BINDING_ANGLE].item);
style->bindings[MS_STYLE_BINDING_ANGLE].item = strdup(msyytext);
style->numbindings++;
} else {
@@ -1926,6 +1940,8 @@
if(symbol == MS_NUMBER)
style->size = (double) msyynumber;
else {
+ if (style->bindings[MS_STYLE_BINDING_SIZE].item != NULL)
+ msFree(style->bindings[MS_STYLE_BINDING_SIZE].item);
style->bindings[MS_STYLE_BINDING_SIZE].item = strdup(msyytext);
style->numbindings++;
}
@@ -1937,8 +1953,14 @@
if(symbol == MS_NUMBER)
style->symbol = (int) msyynumber;
else if(symbol == MS_STRING)
- style->symbolname = strdup(msyytext);
+ {
+ if (style->symbolname != NULL)
+ msFree(style->symbolname);
+ style->symbolname = strdup(msyytext);
+ }
else {
+ if (style->bindings[MS_STYLE_BINDING_SYMBOL].item != NULL)
+ msFree(style->bindings[MS_STYLE_BINDING_SYMBOL].item);
style->bindings[MS_STYLE_BINDING_SYMBOL].item = strdup(msyytext);
style->numbindings++;
}
@@ -1948,6 +1970,8 @@
if(symbol == MS_NUMBER)
style->width = (double) msyynumber;
else {
+ if (style->bindings[MS_STYLE_BINDING_WIDTH].item != NULL)
+ msFree(style->bindings[MS_STYLE_BINDING_WIDTH].item);
style->bindings[MS_STYLE_BINDING_WIDTH].item = strdup(msyytext);
style->numbindings++;
}
@@ -2100,7 +2124,8 @@
* to msGrowClassStyles()
*/
class->numstyles = 0;
- class->maxstyles = 0;
+ class->maxstyles = 0;
+
class->styles = NULL;
class->keyimage = NULL;
@@ -2375,8 +2400,12 @@
if(state == MS_NUMBER)
class->styles[0]->symbol = (int) msyynumber;
else
+ {
+ if (class->styles[0]->symbolname != NULL)
+ msFree(class->styles[0]->symbolname);
class->styles[0]->symbolname = strdup(msyytext);
- class->numstyles = 1;
+ class->numstyles = 1;
+ }
break;
/*
@@ -2413,8 +2442,12 @@
if((state = getSymbol(2, MS_NUMBER,MS_STRING)) == -1) return(-1);
if(state == MS_NUMBER)
class->styles[1]->symbol = (int) msyynumber;
- else
+ else
+ {
+ if (class->styles[1]->symbolname != NULL)
+ msFree(class->styles[1]->symbolname);
class->styles[1]->symbolname = strdup(msyytext);
+ }
class->numstyles = 2;
break;
@@ -3245,7 +3278,11 @@
if(state == MS_NUMBER)
ref->marker = (int) msyynumber;
else
+ {
+ if (ref->markername != NULL)
+ msFree(ref->markername);
ref->markername = strdup(msyytext);
+ }
break;
case(MARKERSIZE):
if(getInteger(&(ref->markersize)) == -1) return(-1);
More information about the mapserver-commits
mailing list