From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Thu, 29 Jun 2023 18:41:18 +0000 (-0700) Subject: [3.11] Fix possible refleak in CodeType.replace() (GH-106243) (GH-106245) X-Git-Tag: v3.11.5~239 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8623812fdc1182dcf580f4954d9d92438fa60a41;p=thirdparty%2FPython%2Fcpython.git [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 --- 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; }