[mapserver-commits] r11370 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Tue Mar 29 17:55:31 EDT 2011
Author: tamas
Date: 2011-03-29 14:55:31 -0700 (Tue, 29 Mar 2011)
New Revision: 11370
Modified:
trunk/mapserver/mapunion.c
Log:
Union layer: Prevent from the crash when failed to open the source layer
Modified: trunk/mapserver/mapunion.c
===================================================================
--- trunk/mapserver/mapunion.c 2011-03-29 21:37:41 UTC (rev 11369)
+++ trunk/mapserver/mapunion.c 2011-03-29 21:55:31 UTC (rev 11370)
@@ -86,6 +86,7 @@
char **layerNames;
mapObj* map;
int i;
+ int layerCount;
if (layer->layerinfo != NULL)
{
@@ -114,10 +115,12 @@
layerinfo->classgroup = NULL;
layerinfo->nclasses = 0;
+
+ layerinfo->layerCount = 0;
- layerNames = msStringSplit(layer->connection, ',', &layerinfo->layerCount);
+ layerNames = msStringSplit(layer->connection, ',', &layerCount);
- if (layerinfo->layerCount == 0)
+ if (layerCount == 0)
{
msSetError(MS_MISCERR, "No source layers specified in layer: %s", layer->name);
if(layerNames)
@@ -126,10 +129,10 @@
return MS_FAILURE;
}
- layerinfo->layers =(layerObj*)malloc(layerinfo->layerCount * sizeof(layerObj));
- MS_CHECK_ALLOC(layerinfo->layers, layerinfo->layerCount * sizeof(layerObj), MS_FAILURE);
+ layerinfo->layers =(layerObj*)malloc(layerCount * sizeof(layerObj));
+ MS_CHECK_ALLOC(layerinfo->layers, layerCount * sizeof(layerObj), MS_FAILURE);
- for(i=0; i < layerinfo->layerCount; i++)
+ for(i=0; i < layerCount; i++)
{
int layerindex = msGetLayerIndex(map, layerNames[i]);
if (layerindex >= 0 && layerindex < map->numlayers)
@@ -155,6 +158,8 @@
return MS_FAILURE;
}
+ ++layerinfo->layerCount;
+
if (msCopyLayer(&layerinfo->layers[i], srclayer) != MS_SUCCESS)
{
msSetError(MS_MISCERR, "Cannot copy source layer: %s", srclayer->name);
More information about the mapserver-commits
mailing list