]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] Fix possible refleak in CodeType.replace() (GH-106243) (GH-106244)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 29 Jun 2023 18:41:01 +0000 (11:41 -0700)
committerGitHub <noreply@github.com>
Thu, 29 Jun 2023 18:41:01 +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 9b54c610581174bedfec4f9c02cccd6b8cd09603..d47ca731a10c87e25b11e2e5f04ddd83d43c3da5 100644 (file)
@@ -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;
     }