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.
This commit is contained in:
Chris Jerdonek 2020-05-08 03:54:38 -07:00 committed by GitHub
parent 02fa0ea9c1
commit d2c349b190
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -0,0 +1 @@
Fix possible memory leak in the C implementation of :class:`asyncio.Task`.

View File

@ -2638,6 +2638,10 @@ task_step_impl(TaskObj *task, PyObject *exc)
coro = task->task_coro; coro = task->task_coro;
if (coro == NULL) { if (coro == NULL) {
PyErr_SetString(PyExc_RuntimeError, "uninitialized Task object"); PyErr_SetString(PyExc_RuntimeError, "uninitialized Task object");
if (clear_exc) {
/* We created 'exc' during this call */
Py_DECREF(exc);
}
return NULL; return NULL;
} }