diff --git a/Objects/codeobject.c b/Objects/codeobject.c index 9b54c610581..d47ca731a10 100644 --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -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; }