]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-120811: Fix reference leak upon `_PyContext_Exit` failure (GH-120812) ...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 22 Jun 2024 11:14:46 +0000 (13:14 +0200)
committerGitHub <noreply@github.com>
Sat, 22 Jun 2024 11:14:46 +0000 (16:44 +0530)
gh-120811: Fix reference leak upon `_PyContext_Exit` failure (GH-120812)
(cherry picked from commit aed31beca9a54b85a1392631a48da80602210f18)

Co-authored-by: Peter <zintensitydev@gmail.com>
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 3937819b3c386cb33436858d49f94a37ac0a749d..63318d1e5974397ba2716d775453a3fcce4793ea 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;
     }