Opened 18 years ago

Closed 18 years ago

Last modified 18 years ago

#1743 closed defect (fixed)

constructors returning object by reference may cause access violation

Reported by: szekerest Owned by: 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 (3)

comment:1 by szekerest, 18 years ago

Resolution: fixed
Status: newclosed
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

comment:2 by sdlime, 18 years ago

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

Steve

comment:3 by dmorissette, 18 years ago

Cc: dmorissette@… added
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.
Note: See TracTickets for help on using tickets.