[mapserver-commits] r10206 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Wed Jun 2 14:18:26 EDT 2010


Author: aboudreault
Date: 2010-06-02 14:18:23 -0400 (Wed, 02 Jun 2010)
New Revision: 10206

Modified:
   trunk/mapserver/mapfile.c
   trunk/mapserver/mappostgis.c
Log:
Fixed memory leak in postgis driver and freeLayer() function

Modified: trunk/mapserver/mapfile.c
===================================================================
--- trunk/mapserver/mapfile.c	2010-06-02 17:33:42 UTC (rev 10205)
+++ trunk/mapserver/mapfile.c	2010-06-02 18:18:23 UTC (rev 10206)
@@ -3121,6 +3121,7 @@
 
   if(&(layer->metadata)) msFreeHashItems(&(layer->metadata));
   if(&(layer->validation)) msFreeHashItems(&(layer->validation));
+  if(&(layer->bindvals))  msFreeHashItems(&layer->bindvals);
 
   if(layer->numprocessing > 0)
       msFreeCharArray(layer->processing, layer->numprocessing);
@@ -5570,7 +5571,7 @@
 /* look in places authorized for url substitution and replace "from" by "to" */ 
 void msLayerSubstituteString(layerObj *layer, const char *from, const char *to) {
   int k;
-  char* bindvals_key = msFirstKeyFromHashTable(&layer->bindvals);
+  char* bindvals_key = (char*)msFirstKeyFromHashTable(&layer->bindvals);
   char* bindvals_val;
 
   if(layer->data && (strcasestr(layer->data, from) != NULL)) 
@@ -5590,7 +5591,7 @@
   while(bindvals_key != NULL) {
     bindvals_val = strdup((char*)msLookupHashTable(&layer->bindvals, bindvals_key));
     msInsertHashTable(&layer->bindvals, bindvals_key, msCaseReplaceSubstring(bindvals_val, from, to));
-    bindvals_key = msNextKeyFromHashTable(&layer->bindvals, bindvals_key);
+    bindvals_key = (char*)msNextKeyFromHashTable(&layer->bindvals, bindvals_key);
   }
 }
   

Modified: trunk/mapserver/mappostgis.c
===================================================================
--- trunk/mapserver/mappostgis.c	2010-06-02 17:33:42 UTC (rev 10205)
+++ trunk/mapserver/mappostgis.c	2010-06-02 18:18:23 UTC (rev 10206)
@@ -1819,6 +1819,10 @@
         pgresult = PQexec(layerinfo->pgconn, strSQL);
     }
 
+    /* free bind values */
+    free(bind_key);
+    free(layer_bind_values);
+
     if ( layer->debug > 1 ) {
         msDebug("msPostGISLayerWhichShapes query status: %s (%d)\n", PQresStatus(PQresultStatus(pgresult)), PQresultStatus(pgresult)); 
     }



More information about the mapserver-commits mailing list