Skip to content

Commit

Permalink
Issue python#117: fix a reference leak in stackless.threads
Browse files Browse the repository at this point in the history
Fix two reference leaks in the C-implementation of stackless.threads.

https://bitbucket.org/stackless-dev/stackless/issues/117
(grafted from 0ed22581e9fc255195d9116446ab9b20bcf99ac8)
  • Loading branch information
Anselm Kruis committed Feb 13, 2017
1 parent 0ad0eac commit 052bcb8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Stackless/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ What's New in Stackless 3.X.X?
- https://bitbucket.org/stackless-dev/stackless/issues/117
Fix various reference leaks:
- Leak of a reference to Py_None in generator.throw()

- Leak of a reference to the thread-id of every thread returned by stackless.threads

Additionally this change brings the handling of caught exceptions more in
line with C-Python.

Expand Down
11 changes: 9 additions & 2 deletions Stackless/module/stacklessmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1524,9 +1524,16 @@ slpmodule_getthreads(PyObject *self)

for (ts = interp->tstate_head; ts != NULL; ts = ts->next) {
PyObject *id = PyLong_FromLong(ts->thread_id);

if (id == NULL || PyList_Append(lis, id))
if (id == NULL) {
Py_DECREF(lis);
return NULL;
}
if (PyList_Append(lis, id)) {
Py_DECREF(lis);
Py_DECREF(id);
return NULL;
}
Py_DECREF(id);
}
PyList_Reverse(lis);
return lis;
Expand Down

0 comments on commit 052bcb8

Please sign in to comment.