[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 3c70d467c1)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
Miss Islington (bot) 2023-06-29 11:41:01 -07:00 committed by GitHub
parent c9b9555650
commit 2405929c35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View 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;
}