From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Thu, 29 Jun 2023 18:41:01 +0000 (-0700) Subject: [3.12] Fix possible refleak in CodeType.replace() (GH-106243) (GH-106244) X-Git-Tag: v3.12.0b4~54 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2405929c35239580aa0344f0e8fd31b87f9ccfe9;p=thirdparty%2FPython%2Fcpython.git [3.12] Fix possible refleak in CodeType.replace() (GH-106243) (GH-106244) 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 9b54c6105811..d47ca731a10c 100644 --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -2030,6 +2030,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; }