Skip to content

Commit 0e4a5e9

Browse files
[3.8] bpo-40559: Add Py_DECREF to _asynciomodule.c:task_step_impl() (GH-19990)
This fixes a possible memory leak in the C implementation of asyncio.Task. (cherry picked from commit d2c349b) Co-authored-by: Chris Jerdonek <[email protected]>
1 parent bce4dda commit 0e4a5e9

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix possible memory leak in the C implementation of :class:`asyncio.Task`.

Modules/_asynciomodule.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2626,6 +2626,10 @@ task_step_impl(TaskObj *task, PyObject *exc)
26262626
coro = task->task_coro;
26272627
if (coro == NULL) {
26282628
PyErr_SetString(PyExc_RuntimeError, "uninitialized Task object");
2629+
if (clear_exc) {
2630+
/* We created 'exc' during this call */
2631+
Py_DECREF(exc);
2632+
}
26292633
return NULL;
26302634
}
26312635

0 commit comments

Comments
 (0)