From 8623812fdc1182dcf580f4954d9d92438fa60a41 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Thu, 29 Jun 2023 11:41:18 -0700 Subject: [PATCH] [3.11] Fix possible refleak in CodeType.replace() (GH-106243) (GH-106245) Fix possible refleak in CodeType.replace() (GH-106243) A reference to c_code was leaked if PySys_Audit() failed. (cherry picked from commit 3c70d467c148875f2ce17bacab8909ecc3e9fc1d) Co-authored-by: Serhiy Storchaka --- Objects/codeobject.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Objects/codeobject.c b/Objects/codeobject.c index 32938b52ab40..77ea4abf35dc 100644 --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -1943,6 +1943,7 @@ code_replace_impl(PyCodeObject *self, int co_argcount, co_code, co_filename, co_name, co_argcount, co_posonlyargcount, co_kwonlyargcount, co_nlocals, co_stacksize, co_flags) < 0) { + Py_XDECREF(code); return NULL; } -- 2.47.3