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:
Olly Betts 2017-09-14 09:32:16 +12:00
commit 0185b6114f

View file

@ -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 "";