[mapserver-commits] r8500 - branches/branch-5-2/mapserver

svn at osgeo.org svn at osgeo.org
Wed Feb 4 20:22:59 EST 2009


Author: aboudreault
Date: 2009-02-04 20:22:59 -0500 (Wed, 04 Feb 2009)
New Revision: 8500

Modified:
   branches/branch-5-2/mapserver/HISTORY.TXT
   branches/branch-5-2/mapserver/mapwms.c
Log:
Fixed WMS request with LAYERS parameter: may cause segmentation fault (#2871)


Modified: branches/branch-5-2/mapserver/HISTORY.TXT
===================================================================
--- branches/branch-5-2/mapserver/HISTORY.TXT	2009-02-05 01:04:26 UTC (rev 8499)
+++ branches/branch-5-2/mapserver/HISTORY.TXT	2009-02-05 01:22:59 UTC (rev 8500)
@@ -13,6 +13,8 @@
 Current Version (SVN branch-5-2)
 --------------------------------
 
+- Fixed WMS request with LAYERS parameter: may cause segmentation fault (#2871)
+
 - fix when layer status = DEFAULT and passing list of layers (#2066)
 
 - Fixed Blobs not filtered in OracleSpatial Attribute/WFS queries (#2829)

Modified: branches/branch-5-2/mapserver/mapwms.c
===================================================================
--- branches/branch-5-2/mapserver/mapwms.c	2009-02-05 01:04:26 UTC (rev 8499)
+++ branches/branch-5-2/mapserver/mapwms.c	2009-02-05 01:22:59 UTC (rev 8500)
@@ -414,7 +414,14 @@
 
     if (strcasecmp(names[i], "LAYERS") == 0)
     {
-      int  j, k, iLayer;
+      int  j, k, iLayer, *layerOrder;
+      
+      layerOrder = (int*)malloc(map->numlayers * sizeof(int));
+      if (layerOrder == NULL)
+      {
+        msSetError(MS_MEMERR, NULL, "msWMSLoadGetMapParams()");
+        return MS_FAILURE;
+      }
 
       layers = msStringSplit(values[i], ',', &numlayers);
       if (layers==NULL || numlayers < 1) {
@@ -425,7 +432,10 @@
 
 
       for (iLayer=0; iLayer < map->numlayers; iLayer++)
+      {
           map->layerorder[iLayer] = iLayer;
+          layerOrder[iLayer] = 0;
+      }
 
       for(j=0; j<map->numlayers; j++)
       {
@@ -434,7 +444,10 @@
         if (GET_LAYER(map, j)->status != MS_DEFAULT)
            GET_LAYER(map, j)->status = MS_OFF;
         else
+        {
            map->layerorder[nLayerOrder++] = j;
+           layerOrder[j] = 1;
+        }
       }
 
       for (k=0; k<numlayers; k++)
@@ -450,8 +463,12 @@
               {
                   if (GET_LAYER(map, j)->status != MS_DEFAULT)
                   {
-                      map->layerorder[nLayerOrder++] = j;
-                      GET_LAYER(map, j)->status = MS_ON;
+                     if (layerOrder[j] == 0)
+                     {
+                        map->layerorder[nLayerOrder++] = j;
+                        layerOrder[j] = 1;
+                        GET_LAYER(map, j)->status = MS_ON;
+                     }
                   }
                   validlayers++;
                   layerfound = 1;
@@ -466,9 +483,11 @@
       for (j=0; j<map->numlayers; j++)
       {
          if (GET_LAYER(map, j)->status == MS_OFF)
-           map->layerorder[nLayerOrder++] = j;
+            if (layerOrder[j] == 0)
+               map->layerorder[nLayerOrder++] = j;
       }
-
+      
+      free(layerOrder);
       msFreeCharArray(layers, numlayers);
     }
     else if (strcasecmp(names[i], "STYLES") == 0) {



More information about the mapserver-commits mailing list