#904 memory leak using t_output_helper

open
nobody
5
2012-12-21
2008-03-27
No

Hello,
I had memory leak using t_output_helper.
The reason is that PyList_SetItem
does not increment the referenc count
while PyList_Append does.
So the first added object is freed properly
and the others leak

SWIGINTERN PyObject*
t_output_helper(PyObject* target, PyObject* o) {
if (!target) {
target = o;
} else if (target == Py_None) {
Py_DECREF(target);
target = o;
} else {
if (!PyList_Check(target)) {
PyObject *o2 = target;
target = PyList_New(1);
PyList_SetItem(target, 0, o2);
}
PyList_Append(target,o);
}
return target;
}

Discussion

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks