From: Serhiy Storchaka Date: Thu, 29 Jun 2023 14:22:15 +0000 (+0300) Subject: Fix possible refleak in CodeType.replace() (GH-106243) X-Git-Tag: v3.13.0a1~1603 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3c70d467c148875f2ce17bacab8909ecc3e9fc1d;p=thirdparty%2FPython%2Fcpython.git Fix possible refleak in CodeType.replace() (GH-106243) A reference to c_code was leaked if PySys_Audit() failed. --- diff --git a/Objects/codeobject.c b/Objects/codeobject.c index a53584c4795e..d2670c71caa4 100644 --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -2035,6 +2035,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; }