From: Chris Jerdonek Date: Fri, 8 May 2020 10:54:38 +0000 (-0700) Subject: bpo-40559: Add Py_DECREF to _asynciomodule.c:task_step_impl() (GH-19990) X-Git-Tag: v3.9.0b1~135 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d2c349b190bcba21a4a38e6520a48ad97a9f1529;p=thirdparty%2FPython%2Fcpython.git 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. --- diff --git a/Misc/NEWS.d/next/Library/2020-05-05-08-12-51.bpo-40559.112wwa.rst b/Misc/NEWS.d/next/Library/2020-05-05-08-12-51.bpo-40559.112wwa.rst new file mode 100644 index 000000000000..15846351f25b --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-05-05-08-12-51.bpo-40559.112wwa.rst @@ -0,0 +1 @@ +Fix possible memory leak in the C implementation of :class:`asyncio.Task`. \ No newline at end of file diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c index a03a63119bab..cc211a8895a8 100644 --- a/Modules/_asynciomodule.c +++ b/Modules/_asynciomodule.c @@ -2638,6 +2638,10 @@ task_step_impl(TaskObj *task, PyObject *exc) coro = task->task_coro; if (coro == NULL) { PyErr_SetString(PyExc_RuntimeError, "uninitialized Task object"); + if (clear_exc) { + /* We created 'exc' during this call */ + Py_DECREF(exc); + } return NULL; }