[mapserver-commits] r7950 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Fri Oct 3 17:51:57 EDT 2008


Author: pramsey
Date: 2008-10-03 17:51:57 -0400 (Fri, 03 Oct 2008)
New Revision: 7950

Modified:
   trunk/mapserver/HISTORY.TXT
   trunk/mapserver/mapobject.c
Log:
memory leak in msInsertLayer, from Ned Horning (#2784)



Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2008-10-03 21:48:09 UTC (rev 7949)
+++ trunk/mapserver/HISTORY.TXT	2008-10-03 21:51:57 UTC (rev 7950)
@@ -11,6 +11,9 @@
 
 Current Version (5.3-dev, SVN trunk):
 ------------------------------------
+
+- memory leak in msInsertLayer, from Ned Horning (#2784)
+
 - label size computation refactoring (#2390)
 
 - don't draw label background if we're using angle follow. (#2726)

Modified: trunk/mapserver/mapobject.c
===================================================================
--- trunk/mapserver/mapobject.c	2008-10-03 21:48:09 UTC (rev 7949)
+++ trunk/mapserver/mapobject.c	2008-10-03 21:51:57 UTC (rev 7950)
@@ -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