]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] Fix possible refleak in CodeType.replace() (GH-106243) (GH-106245)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 29 Jun 2023 18:41:18 +0000 (11:41 -0700)
committerGitHub <noreply@github.com>
Thu, 29 Jun 2023 18:41:18 +0000 (21:41 +0300)
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 <storchaka@gmail.com>
Objects/codeobject.c

index 32938b52ab40f2006e117c2dece7316b839aa58d..77ea4abf35dca92d17e2ac710a6a4aca4489504f 100644 (file)
@@ -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;
     }