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

svn at osgeo.org svn at osgeo.org
Fri Oct 3 17:52:15 EDT 2008


Author: pramsey
Date: 2008-10-03 17:52:15 -0400 (Fri, 03 Oct 2008)
New Revision: 7951

Modified:
   branches/branch-5-2/mapserver/HISTORY.TXT
   branches/branch-5-2/mapserver/mapobject.c
Log:
memory leak in msInsertLayer, from Ned Horning (#2784)



Modified: branches/branch-5-2/mapserver/HISTORY.TXT
===================================================================
--- branches/branch-5-2/mapserver/HISTORY.TXT	2008-10-03 21:51:57 UTC (rev 7950)
+++ branches/branch-5-2/mapserver/HISTORY.TXT	2008-10-03 21:52:15 UTC (rev 7951)
@@ -13,6 +13,8 @@
 Current Version (SVN branch-5-2)
 --------------------------------
 
+- memory leak in msInsertLayer, from Ned Horning (#2784)
+
 - legend keyimage resampling with agg (#2715)
 
 - tileindexed rasters when DATA is manipulated via mapscript work (#2783)

Modified: branches/branch-5-2/mapserver/mapobject.c
===================================================================
--- branches/branch-5-2/mapserver/mapobject.c	2008-10-03 21:51:57 UTC (rev 7950)
+++ branches/branch-5-2/mapserver/mapobject.c	2008-10-03 21:52:15 UTC (rev 7951)
@@ -498,10 +498,20 @@
     }
 
     /* Ensure there is room for a new layer */
-    if (msGrowMapLayers(map) == NULL)
-        return -1;
-    /* Catch attempt to insert past end of layers array */
-    else if (nIndex >= map->numlayers) {
+    if (map->numlayers == map->maxlayers)
+              {
+                              if (msGrowMapLayers(map) == NULL)
+                                              return -1;
+              }
+
+              /* msGrowMapLayers allocates the new layer which we don't need to do since we have 1 that we are inserting 
+                              not sure if it is possible for this to be non null otherwise, but better to check since this function
+                              replaces the value */
+              if (map->layers[map->numlayers]!=NULL)
+                              free(map->layers[map->numlayers]);
+
+              /* Catch attempt to insert past end of layers array */
+              if (nIndex >= map->numlayers) {
         msSetError(MS_CHILDERR, "Cannot insert layer beyond index %d",
                    "msInsertLayer()", map->numlayers-1);
         return -1;



More information about the mapserver-commits mailing list