]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix possible refleak in CodeType.replace() (GH-106243)
authorSerhiy Storchaka <storchaka@gmail.com>
Thu, 29 Jun 2023 14:22:15 +0000 (17:22 +0300)
committerGitHub <noreply@github.com>
Thu, 29 Jun 2023 14:22:15 +0000 (17:22 +0300)
A reference to c_code was leaked if PySys_Audit() failed.

Objects/codeobject.c

index a53584c4795e9092127dff059ff499ce87a85e9c..d2670c71caa44a09a35ab9fb0fc5fb904e230e45 100644 (file)
@@ -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;
     }