Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
[fix] PyList_Append is known to memleak #1019
small one really, PyList_Append is known to leak.
This comment has been minimized.
This comment has been minimized.Show comment Hide comment
An alternative fix is to use a temporary:
PyObject *obj = Py_BuildValue(...);
Either is fine. The only advantage of this version is you could add error checking (ensuring obj is created successfully) if you wanted to, though I suspect we don't do this anywhere else.
If you stick with your method here (make sure you preallocate the list the right size as in your link), it might pay to add a comment that PyList_SetItem() steals the ref count, so no need to DECREF.