]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.8] bpo-40559: Add Py_DECREF to _asynciomodule.c:task_step_impl() (GH-19990)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 8 May 2020 11:28:38 +0000 (04:28 -0700)
committerGitHub <noreply@github.com>
Fri, 8 May 2020 11:28:38 +0000 (04:28 -0700)
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>
Misc/NEWS.d/next/Library/2020-05-05-08-12-51.bpo-40559.112wwa.rst [new file with mode: 0644]
Modules/_asynciomodule.c

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 (file)
index 0000000..1584635
--- /dev/null
@@ -0,0 +1 @@
+Fix possible memory leak in the C implementation of :class:`asyncio.Task`.
\ No newline at end of file
index 5ba2bc4975709895a0bdb5660be3dd808d486043..8e1cd4f52a540a285ce10c0d23bda1195a73818d 100644 (file)
@@ -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;
     }