Skip to content

Commit

Permalink
Fixed mapscript is unusable in a web application due to memory leaks (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Boudreault committed May 2, 2012
1 parent ad10ce4 commit 94ccfcd
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
2 changes: 2 additions & 0 deletions HISTORY.TXT
Expand Up @@ -14,6 +14,8 @@ For a complete change history, please see the Git log comments.
Current Version (future 6.0.3, SVN branch-6-0):
-----------------------------------------------

- Fixed mapscript is unusable in a web application due to memory leaks (#4262)

- Fixed getFeature request with custom output format fails on filter encoding (#4190)

- Fixed resolution when UoM changes in WCS 2.0 (#4283)
Expand Down
6 changes: 3 additions & 3 deletions mapdraw.c
Expand Up @@ -1302,15 +1302,15 @@ msDrawRasterLayerPlugin( mapObj *map, layerObj *layer, imageObj *image)
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;
}

Expand Down
14 changes: 10 additions & 4 deletions mapobject.c
Expand Up @@ -781,7 +781,7 @@ int msMapLoadOWSParameters(mapObj *map, cgiRequestObj *request,
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;
Expand All @@ -800,9 +800,15 @@ int msMapLoadOWSParameters(mapObj *map, cgiRequestObj *request,

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()");
Expand Down
5 changes: 3 additions & 2 deletions mapscript/swiginc/msio.i
Expand Up @@ -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 */
Expand Down Expand Up @@ -89,7 +90,7 @@ gdBuffer msIO_getStdoutBufferBytes() {

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;
Expand Down
12 changes: 2 additions & 10 deletions mapscript/swiginc/owsrequest.i
Expand Up @@ -53,14 +53,10 @@ static char *msGetEnvURL( const char *key, void *thread_context )

%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()");
Expand All @@ -70,13 +66,9 @@ static char *msGetEnvURL( const char *key, void *thread_context )
return request;
}

#if defined(SWIGJAVA) || defined(SWIGCSHARP)
~cgiRequestObj()
#else
~cgiRequestObj(void)
#endif
{
free(self);
msFreeCgiObj(self);
}

int loadParams()
Expand Down

0 comments on commit 94ccfcd

Please sign in to comment.