[mapserver-commits] r10689 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Fri Oct 29 16:48:15 EDT 2010
Author: rouault
Date: 2010-10-29 13:48:15 -0700 (Fri, 29 Oct 2010)
New Revision: 10689
Modified:
trunk/mapserver/mapgml.c
trunk/mapserver/mapwfs.c
trunk/mapserver/mapwfs11.c
Log:
Fix memory leaks found by valgrind on wfs_misc.map and wfs_simple.map
Modified: trunk/mapserver/mapgml.c
===================================================================
--- trunk/mapserver/mapgml.c 2010-10-29 17:32:52 UTC (rev 10688)
+++ trunk/mapserver/mapgml.c 2010-10-29 20:48:15 UTC (rev 10689)
@@ -779,6 +779,7 @@
msFree(geometryList->geometries[i].name);
msFree(geometryList->geometries[i].type);
}
+ free(geometryList->geometries);
free(geometryList);
}
Modified: trunk/mapserver/mapwfs.c
===================================================================
--- trunk/mapserver/mapwfs.c 2010-10-29 17:32:52 UTC (rev 10688)
+++ trunk/mapserver/mapwfs.c 2010-10-29 20:48:15 UTC (rev 10689)
@@ -669,7 +669,7 @@
return msWFSGetCapabilities11( map, wfsparams, req );
/* Decide which version we're going to return... only 1.0.0 for now */
- wmtver = strdup("1.0.0");
+ wmtver = "1.0.0";
/* We need this server's onlineresource. */
if ((script_url=msOWSGetOnlineResource(map, "FO", "onlineresource", req)) == NULL ||
@@ -678,6 +678,8 @@
msSetError(MS_WFSERR, "Server URL not found", "msWFSGetCapabilities()");
return msWFSException(map, "mapserv", "NoApplicableCode", wmtver);
}
+ free(script_url);
+ script_url = NULL;
updatesequence = msOWSLookupMetadata(&(map->web.metadata), "FO", "updatesequence");
@@ -688,10 +690,12 @@
i = msOWSNegotiateUpdateSequence(wfsparams->pszUpdateSequence, updatesequence);
if (i == 0) { /* current */
msSetError(MS_WFSERR, "UPDATESEQUENCE parameter (%s) is equal to server (%s)", "msWFSGetCapabilities()", wfsparams->pszUpdateSequence, updatesequence);
+ free(script_url_encoded);
return msWFSException(map, "updatesequence", "CurrentUpdateSequence", wmtver);
}
if (i > 0) { /* invalid */
msSetError(MS_WFSERR, "UPDATESEQUENCE parameter (%s) is higher than server (%s)", "msWFSGetCapabilities()", wfsparams->pszUpdateSequence, updatesequence);
+ free(script_url_encoded);
return msWFSException(map, "updatesequence", "InvalidUpdateSequence", wmtver);
}
}
@@ -845,7 +849,6 @@
*/
msIO_printf("</WFS_Capabilities>\n");
- free(script_url);
free(script_url_encoded);
return MS_SUCCESS;
@@ -2869,28 +2872,19 @@
{
if (wfsparams)
{
- if (wfsparams->pszVersion)
- free(wfsparams->pszVersion);
- if (wfsparams->pszUpdateSequence)
- free(wfsparams->pszUpdateSequence);
- if (wfsparams->pszRequest)
- free(wfsparams->pszRequest);
- if (wfsparams->pszService)
- free(wfsparams->pszService);
- if (wfsparams->pszTypeName)
- free(wfsparams->pszTypeName);
- if (wfsparams->pszFilter)
- free(wfsparams->pszFilter);
- if (wfsparams->pszFeatureId)
- free(wfsparams->pszFeatureId);
- if (wfsparams->pszOutputFormat)
- free(wfsparams->pszOutputFormat);
- if (wfsparams->pszSrs)
- free(wfsparams->pszSrs);
- if (wfsparams->pszResultType)
- free(wfsparams->pszResultType);
- if (wfsparams->pszAcceptVersions)
- free(wfsparams->pszAcceptVersions);
+ free(wfsparams->pszVersion);
+ free(wfsparams->pszUpdateSequence);
+ free(wfsparams->pszRequest);
+ free(wfsparams->pszService);
+ free(wfsparams->pszTypeName);
+ free(wfsparams->pszFilter);
+ free(wfsparams->pszBbox);
+ free(wfsparams->pszOutputFormat);
+ free(wfsparams->pszFeatureId);
+ free(wfsparams->pszSrs);
+ free(wfsparams->pszResultType);
+ free(wfsparams->pszPropertyName);
+ free(wfsparams->pszAcceptVersions);
}
}
Modified: trunk/mapserver/mapwfs11.c
===================================================================
--- trunk/mapserver/mapwfs11.c 2010-10-29 17:32:52 UTC (rev 10688)
+++ trunk/mapserver/mapwfs11.c 2010-10-29 20:48:15 UTC (rev 10689)
@@ -109,6 +109,7 @@
const char *value = NULL;
const char *encoding = NULL;
char *encoded=NULL;
+ char *valueToFree;
char **tokens;
int n=0,i=0;
@@ -156,13 +157,13 @@
msFree(encoded);
}
/*support DefaultSRS and OtherSRS*/
- value = msOWSGetProjURN(&(map->projection),&(map->web.metadata),"FO",MS_FALSE);
- if (!value)
- value = msOWSGetProjURN(&(lp->projection), &(lp->metadata), "FO", MS_FALSE);
+ valueToFree = msOWSGetProjURN(&(map->projection),&(map->web.metadata),"FO",MS_FALSE);
+ if (!valueToFree)
+ valueToFree = msOWSGetProjURN(&(lp->projection), &(lp->metadata), "FO", MS_FALSE);
- if (value)
+ if (valueToFree)
{
- tokens = msStringSplit(value, ' ', &n);
+ tokens = msStringSplit(valueToFree, ' ', &n);
if (tokens && n > 0)
{
psNode = xmlNewChild(psRootNode, NULL, BAD_CAST "DefaultSRS", BAD_CAST tokens[0]);
@@ -176,6 +177,9 @@
xmlAddSibling(psNode,
xmlNewComment(BAD_CAST "WARNING: Mandatory mapfile parameter: (at least one of) MAP.PROJECTION, LAYER.PROJECTION or wfs/ows_srs metadata was missing in this context."));
+ free(valueToFree);
+ valueToFree = NULL;
+
/*TODO: adevertize only gml3?*/
psNode = xmlNewNode(NULL, BAD_CAST "OutputFormats");
xmlAddChild(psRootNode, psNode);
More information about the mapserver-commits
mailing list