Skip to content

Commit 2501428

Browse files
[3.7] 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 d64fd61 commit 2501428

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
@@ -2567,6 +2567,10 @@ task_step_impl(TaskObj *task, PyObject *exc)
25672567
coro = task->task_coro;
25682568
if (coro == NULL) {
25692569
PyErr_SetString(PyExc_RuntimeError, "uninitialized Task object");
2570+
if (clear_exc) {
2571+
/* We created 'exc' during this call */
2572+
Py_DECREF(exc);
2573+
}
25702574
return NULL;
25712575
}
25722576

0 commit comments

Comments
 (0)