Skip to content

Commit

Permalink
msLoadMapContextGeneral(): fix memory leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Jan 3, 2023
1 parent 7589699 commit ffb4c72
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions mapcontext.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@ int msLoadMapContextGeneral(mapObj *map, CPLXMLNode *psGeneral,
sprintf(pszProj, "init=epsg:%s", pszValue+5);
}

msFreeProjection(&map->projection);
msInitProjection(&map->projection);
map->projection.args[map->projection.numargs] = msStrdup(pszProj);
map->projection.numargs++;
Expand Down Expand Up @@ -752,12 +753,20 @@ int msLoadMapContextGeneral(mapObj *map, CPLXMLNode *psGeneral,
pszValue = (char*)CPLGetXMLValue(psMapContext,
"id", NULL);
if (pszValue)
{
msFree(map->name);
map->name = msStrdup(pszValue);
}
} else {
char* pszMapName = NULL;
if(msGetMapContextXMLStringValue(psGeneral, "Name",
&(map->name)) == MS_FAILURE) {
&pszMapName) == MS_FAILURE) {
msGetMapContextXMLStringValue(psGeneral, "gml:name",
&(map->name));
&pszMapName);
}
if( pszMapName ) {
msFree(map->name);
map->name = pszMapName;
}
}
/* Keyword */
Expand Down

0 comments on commit ffb4c72

Please sign in to comment.