]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-120811: Fix reference leak upon `_PyContext_Exit` failure (#120812)
authorPeter <zintensitydev@gmail.com>
Fri, 21 Jun 2024 17:28:19 +0000 (12:28 -0500)
committerGitHub <noreply@github.com>
Fri, 21 Jun 2024 17:28:19 +0000 (17:28 +0000)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Misc/NEWS.d/next/Library/2024-06-21-14-32-56.gh-issue-120811.eBmVTV.rst [new file with mode: 0644]
Python/context.c

diff --git a/Misc/NEWS.d/next/Library/2024-06-21-14-32-56.gh-issue-120811.eBmVTV.rst b/Misc/NEWS.d/next/Library/2024-06-21-14-32-56.gh-issue-120811.eBmVTV.rst
new file mode 100644 (file)
index 0000000..62cd7b5
--- /dev/null
@@ -0,0 +1 @@
+Fix possible memory leak in :meth:`contextvars.Context.run`.
index 42000b13038834cd42b229f0b211cab003fe982f..a3830be17908feb2ab8ff8be2120b0de44ed652b 100644 (file)
@@ -661,6 +661,7 @@ context_run(PyContext *self, PyObject *const *args,
         ts, args[0], args + 1, nargs - 1, kwnames);
 
     if (_PyContext_Exit(ts, (PyObject *)self)) {
+        Py_XDECREF(call_result);
         return NULL;
     }