Fix memory leaks in SWIGTYPE typemaps
The "out" and "directorin" typemaps allocate a new object, but weren't specifying that this object should be owned.
This commit is contained in:
parent
f72d9c1f21
commit
0185b6114f
1 changed files with 3 additions and 3 deletions
|
|
@ -438,19 +438,19 @@
|
|||
#ifdef __cplusplus
|
||||
{
|
||||
$&1_ltype resultobj = new $1_ltype((const $1_ltype &) $1);
|
||||
SWIG_SetZval(return_value, $needNewFlow, $owner, (void *)resultobj, $&1_descriptor, $zend_obj);
|
||||
SWIG_SetZval(return_value, $needNewFlow, 1, (void *)resultobj, $&1_descriptor, $zend_obj);
|
||||
}
|
||||
#else
|
||||
{
|
||||
$&1_ltype resultobj = ($&1_ltype) emalloc(sizeof($1_type));
|
||||
memcpy(resultobj, &$1, sizeof($1_type));
|
||||
SWIG_SetZval(return_value, $needNewFlow, $owner, (void *)resultobj, $&1_descriptor, $zend_obj);
|
||||
SWIG_SetZval(return_value, $needNewFlow, 1, (void *)resultobj, $&1_descriptor, $zend_obj);
|
||||
}
|
||||
#endif
|
||||
|
||||
%typemap(directorin) SWIGTYPE
|
||||
%{
|
||||
SWIG_SetZval($input, $needNewFlow, $owner, SWIG_as_voidptr(new $1_ltype((const $1_ltype &)$1)), $&1_descriptor, $zend_obj);
|
||||
SWIG_SetZval($input, $needNewFlow, 1, SWIG_as_voidptr(new $1_ltype((const $1_ltype &)$1)), $&1_descriptor, $zend_obj);
|
||||
%}
|
||||
|
||||
%typemap(out) void "";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue