[mapserver-commits] r13307 - in trunk/mapserver: . mapscript/swiginc

svn at osgeo.org svn at osgeo.org
Mon Mar 26 14:47:24 EDT 2012


Author: aboudreault
Date: 2012-03-26 11:47:24 -0700 (Mon, 26 Mar 2012)
New Revision: 13307

Modified:
   trunk/mapserver/HISTORY.TXT
   trunk/mapserver/mapdraw.c
   trunk/mapserver/mapobject.c
   trunk/mapserver/mapscript/swiginc/msio.i
   trunk/mapserver/mapscript/swiginc/owsrequest.i
Log:
Fixed mapscript is unusable in a web application due to memory leaks (#4262)

Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2012-03-26 06:56:27 UTC (rev 13306)
+++ trunk/mapserver/HISTORY.TXT	2012-03-26 18:47:24 UTC (rev 13307)
@@ -15,6 +15,8 @@
 Current Version (SVN trunk, 6.1-dev, future 6.2): 
 -------------------------------------------------
 
+- Fixed mapscript is unusable in a web application due to memory leaks (#4262)
+ 
 - Fixed legend image problem with annotation layers with label offsets (#4147)
 
 - Add support for mutiple labels per feature (RFC81)

Modified: trunk/mapserver/mapdraw.c
===================================================================
--- trunk/mapserver/mapdraw.c	2012-03-26 06:56:27 UTC (rev 13306)
+++ trunk/mapserver/mapdraw.c	2012-03-26 18:47:24 UTC (rev 13307)
@@ -1433,15 +1433,15 @@
         	renderer->mergeRasterBuffer( image, rb, 1.0, 0, 0, 0, 0, rb->width, rb->height );
         }
 
-        msFreeRasterBuffer(rb);
-        free(rb); 
-        
+	msFreeRasterBuffer(rb);
     }
 #define RB_GET_R(rb,x,y) *((rb)->data.rgba.r + (x) * (rb)->data.rgba.pixel_step + (y) * (rb)->data.rgba.row_step)
 #define RB_GET_G(rb,x,y) *((rb)->data.rgba.g + (x) * (rb)->data.rgba.pixel_step + (y) * (rb)->data.rgba.row_step)
 #define RB_GET_B(rb,x,y) *((rb)->data.rgba.b + (x) * (rb)->data.rgba.pixel_step + (y) * (rb)->data.rgba.row_step)
 #define RB_GET_A(rb,x,y) *((rb)->data.rgba.a + (x) * (rb)->data.rgba.pixel_step + (y) * (rb)->data.rgba.row_step)
 
+    free(rb);         
+	
     return ret;
 }
 

Modified: trunk/mapserver/mapobject.c
===================================================================
--- trunk/mapserver/mapobject.c	2012-03-26 06:56:27 UTC (rev 13306)
+++ trunk/mapserver/mapobject.c	2012-03-26 18:47:24 UTC (rev 13307)
@@ -781,7 +781,7 @@
     int version;
     char *wms_exception_format = NULL;
     const char *wms_request= NULL;
-    int i =0;
+    int result, i = 0;
     owsRequestObj ows_request;
 
     ows_request.numlayers = 0;
@@ -800,9 +800,15 @@
 
      msOWSRequestLayersEnabled(map, "M", wms_request, &ows_request);
 
-     return msWMSLoadGetMapParams(map, version, request->ParamNames,
-                                  request->ParamValues, request->NumParams,  wms_exception_format, 
-                                  wms_request, &ows_request);
+     result = msWMSLoadGetMapParams(map, version, request->ParamNames,
+				    request->ParamValues, request->NumParams,  wms_exception_format, 
+				    wms_request, &ows_request);
+
+     if (ows_request.numlayers > 0)
+       msFree(ows_request.enabled_layers);
+
+     return result;
+
 #else
     msSetError(MS_WMSERR, "WMS server support is not available.",
                "msMapLoadOWSParameters()");

Modified: trunk/mapserver/mapscript/swiginc/msio.i
===================================================================
--- trunk/mapserver/mapscript/swiginc/msio.i	2012-03-26 06:56:27 UTC (rev 13306)
+++ trunk/mapserver/mapscript/swiginc/msio.i	2012-03-26 18:47:24 UTC (rev 13307)
@@ -36,7 +36,8 @@
 void msIO_resetHandlers(void);
 void msIO_installStdoutToBuffer(void);
 void msIO_installStdinFromBuffer(void);
-const char *msIO_stripStdoutBufferContentType(void);
+%newobject msIO_stripStdoutBufferContentType;
+const char *msIO_stripStdoutBufferContentType();
 void msIO_stripStdoutBufferContentHeaders(void);
 
 /* mapscript only extensions */
@@ -89,7 +90,7 @@
 
     gdBuf.data = buf->data;
     gdBuf.size = buf->data_offset;
-    gdBuf.owns_data = MS_FALSE;
+    gdBuf.owns_data = MS_TRUE;
 
     /* we are seizing ownership of the buffer contents */
     buf->data_offset = 0;

Modified: trunk/mapserver/mapscript/swiginc/owsrequest.i
===================================================================
--- trunk/mapserver/mapscript/swiginc/owsrequest.i	2012-03-26 06:56:27 UTC (rev 13306)
+++ trunk/mapserver/mapscript/swiginc/owsrequest.i	2012-03-26 18:47:24 UTC (rev 13307)
@@ -53,14 +53,10 @@
 
 %extend cgiRequestObj {
 
-#if defined(SWIGJAVA) || defined(SWIGCSHARP)
     cgiRequestObj()
-#else
-    cgiRequestObj(void)
-#endif
     {
         cgiRequestObj *request;
-        
+
         request = msAllocCgiObj();
         if (!request) {
             msSetError(MS_CGIERR, "Failed to initialize object","OWSRequest()");
@@ -70,13 +66,9 @@
         return request;
     }
 
-#if defined(SWIGJAVA) || defined(SWIGCSHARP)
     ~cgiRequestObj()
-#else
-    ~cgiRequestObj(void)
-#endif
     {
-        free(self);
+        msFreeCgiObj(self);
     }
 
     int loadParams()



More information about the mapserver-commits mailing list