[Matrix-SIG] Numpy: memory leak in tolist() fixed
Jonah Lee
ffjhl@uaf.edu
Tue, 9 Feb 1999 13:05:10 -0900 (AKST)
Hi,
I finally got some time to fix this known memory leak in arrayobject.c.
The fix is based upon the suggestion from David Ascher. The diff file is
1214,1219c1214
< PyObject *v=array_item((PyArrayObject *)self, i);
< PyList_SetItem(lp, i, PyArray_ToList(v));
< if (((PyArrayObject *)self)->nd>1){
< Py_DECREF(v);
< }
<
---
> PyList_SetItem(lp, i, PyArray_ToList(array_item((PyArrayObject *)self, i)));
Regards,
Jonah