Ticket #1743 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

constructors returning object by reference may cause access violation

Reported by: szekerest Assigned to: szekerest
Priority: high Milestone:
Component: MapScript-SWIG Version: unspecified
Severity: critical Keywords:
Cc:

Description

Some of the mapscript objects have constructors with parameters containing the
reference of the parent object (eg. layerObj, classObj, styleObj).
Depending on the parameter the current implementation of thoose constructors
return a newly created object or a reference on an existing object.
The current SWIG C# implementation always treats the constructed object as a
newly created object so the destruction of the contained unmanaged memory may be
executed twice.
Deterministic finalization of constructed object may prevent this error to be
manifested, since the desctuctor calls free only if the parent object does not
exist.

Change History

04/10/06 10:01:11 changed by szekerest

  • status changed from new to closed.
  • resolution set to fixed.
Added the changes for preventing to take ownership of the memory when
constructing objects with parent objects using C# mapscript (csmodule.i)

committed to CVS-HEAD, CVS-4-8

06/16/06 17:10:15 changed by sdlime

I guess we need to look at csmodule.i with regards to the other languages.

Steve

06/21/06 08:44:57 changed by dmorissette

  • cc set to dmorissette@mapgears.com.
For the record, PHP MapScript doesn't suffer of this problem since the layerObj,
classObj and styleObj constructors do not accept a NULL parent reference. e.g.
passing a NULL map reference to ms_newLayerObj() would trigger an error right away.