[mapserver-commits] r7833 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Mon Jul 28 23:51:35 EDT 2008


Author: sdlime
Date: 2008-07-28 23:51:35 -0400 (Mon, 28 Jul 2008)
New Revision: 7833

Modified:
   trunk/mapserver/maplayer.c
Log:
Patched a memory leak with logical expressions when a layer is repeatedly opened and closed. (#2702).

Modified: trunk/mapserver/maplayer.c
===================================================================
--- trunk/mapserver/maplayer.c	2008-07-28 14:13:14 UTC (rev 7832)
+++ trunk/mapserver/maplayer.c	2008-07-29 03:51:35 UTC (rev 7833)
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id:$
+ * $Id$
  *
  * Project:  MapServer
  * Purpose:  Implementation of most layerObj functions.
@@ -171,6 +171,8 @@
 */
 void msLayerClose(layerObj *layer) 
 {
+  int i;
+
   /* no need for items once the layer is closed */
   msLayerFreeItemInfo(layer);
   if(layer->items) {
@@ -179,6 +181,15 @@
     layer->numitems = 0;
   }
 
+  /* clear out items used as part of expressions (bug #2702) */
+  for(i=0; i<layer->numclasses; i++) {    
+    msFreeCharArray(layer->class[i]->expression.items, layer->class[i]->expression.numitems);
+    msFree(layer->class[i]->expression.indexes);
+    layer->class[i]->expression.items = NULL;
+    layer->class[i]->expression.indexes = NULL;
+    layer->class[i]->expression.numitems = 0;        
+  }
+
   if (layer->vtable) {
     layer->vtable->LayerClose(layer);
   }



More information about the mapserver-commits mailing list