Skip to content

Commit d2c349b

Browse files
authored
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.
1 parent 02fa0ea commit d2c349b

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed
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

+4
Original file line numberDiff line numberDiff line change
@@ -2638,6 +2638,10 @@ task_step_impl(TaskObj *task, PyObject *exc)
26382638
coro = task->task_coro;
26392639
if (coro == NULL) {
26402640
PyErr_SetString(PyExc_RuntimeError, "uninitialized Task object");
2641+
if (clear_exc) {
2642+
/* We created 'exc' during this call */
2643+
Py_DECREF(exc);
2644+
}
26412645
return NULL;
26422646
}
26432647

0 commit comments

Comments
 (0)