Ticket #73 (closed defect: fixed)

Opened 12 years ago

Last modified 11 years ago

Perl MapScript - Some methods leak string buffers

Reported by: dmorissette Owned by: sdlime
Priority: high Milestone:
Component: MapScript Version: 3.5
Severity: normal Keywords:
Cc:

Description

Some new methods have been added recently that return allocated string buffers 
and the returned strings are never freed.

This problem applies to the following methods:
  layerObj->getWMSFeatureInfoURL()
  layerObj->getProjection()
  mapObj->getProjection()

--------

Stephen Lime wrote:
> 
> Heard back from one person, the gist being that unless it could be handled by 
the
> layer destructor (don't think this can) you have to free it by hand. There 
might be
> a way to edit the wrapper code but that involves hand editing which isn't 
practical.
> Let's see if anyone else chimes in. The scripting languages track references 
so I
> don't know why one couldn't link going out of scope (i.e. undef $string) to an
> underlying function call (i.e. free).
> 
> Steve
> 
> Stephen Lime
> Data & Applications Manager
> 
> Minnesota DNR
> 500 Lafayette Road
> St. Paul, MN 55155
> 651-297-2937
> 
> >>> Daniel Morissette <morissette@dmsolutions.ca> 10/31/01 07:21PM >>>
> Steve,
> 
> I'm adding a layerObj->getWMSFeatureInfoURL() method in mapscript.i to
> be used to fetch a GetFeatureInfo URL from a WMS layer in the mapObj.
> 
> My function returns a newly allocated string that should be freed by the
> caller... how should this be handled in mapscript.i to avoid leaking the
> string buffer?  Is there a way to tell SWIG that the returned string
> should be freed by the script when it's done?
>

Change History

Changed 11 years ago by sdlime

  • status changed from new to closed
  • resolution set to fixed
Finally found the Swig directive to fix this. Now the scripting environment
makes a copy of the strings and deletes the C versions. Works with Swig 1.3.11,
not sure on 1.1-883 though. We need to use the 1.3.x stuff for Java and
potentially PHP support so I'm not terribly worried if it's backwards
compatible. Nobody should really be running Swig anyway.
Note: See TracTickets for help on using tickets.