bpo-46476: Fix memory leak in code objects generated by deepfreeze (GH-30853)

Add _Py_Deepfreeze_Fini() and _PyStaticCode_Dealloc() functions.
This commit is contained in:
Kumar Aditya 2022-01-27 18:33:47 +05:30 committed by GitHub
parent ecfacc362d
commit c7f810b34d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 39 additions and 0 deletions

View file

@ -1906,3 +1906,18 @@ _PyCode_ConstantKey(PyObject *op)
}
return key;
}
void
_PyStaticCode_Dealloc(PyCodeObject *co, _Py_CODEUNIT *firstinstr)
{
PyMem_Free(co->co_quickened);
co->co_quickened = NULL;
PyMem_Free(co->co_extra);
co->co_extra = NULL;
co->co_firstinstr = firstinstr;
if (co->co_weakreflist != NULL) {
PyObject_ClearWeakRefs((PyObject *)co);
co->co_weakreflist = NULL;
}
co->co_warmup = QUICKENING_INITIAL_WARMUP_VALUE;
}