diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-05-08 11:28:38 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-08 11:28:38 (GMT) |
commit | 0e4a5e96f011989736bde824ab817146bd7c9cfc (patch) | |
tree | 888ace0c55e2da9010ec7791da9149b040647e40 | |
parent | bce4ddafdd188cc6deb1584728b67b9e149ca6a4 (diff) | |
download | cpython-0e4a5e96f011989736bde824ab817146bd7c9cfc.zip cpython-0e4a5e96f011989736bde824ab817146bd7c9cfc.tar.gz cpython-0e4a5e96f011989736bde824ab817146bd7c9cfc.tar.bz2 |
[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 d2c349b190bcba21a4a38e6520a48ad97a9f1529)
Co-authored-by: Chris Jerdonek <chris.jerdonek@gmail.com>
-rw-r--r-- | Misc/NEWS.d/next/Library/2020-05-05-08-12-51.bpo-40559.112wwa.rst | 1 | ||||
-rw-r--r-- | Modules/_asynciomodule.c | 4 |
2 files changed, 5 insertions, 0 deletions
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 0000000..1584635 --- /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 5ba2bc4..8e1cd4f 100644 --- a/Modules/_asynciomodule.c +++ b/Modules/_asynciomodule.c @@ -2626,6 +2626,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; } |