]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-40559: Add Py_DECREF to _asynciomodule.c:task_step_impl() (GH-19990)
authorChris Jerdonek <chris.jerdonek@gmail.com>
Fri, 8 May 2020 10:54:38 +0000 (03:54 -0700)
committerGitHub <noreply@github.com>
Fri, 8 May 2020 10:54:38 +0000 (03:54 -0700)
This fixes a possible memory leak in the C implementation of
asyncio.Task.

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 a03a63119bab3d6fba58135f31970f16c24be403..cc211a8895a8e8c5d8135d61b1a1fde096086a63 100644 (file)
@@ -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;
     }