gh-95756: Free and NULL-out code caches when needed (GH-98181)

This commit is contained in:
Ken Jin 2022-10-11 23:11:46 +08:00 committed by GitHub
parent 4067c6d7fe
commit 7ec2e279fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 0 deletions

View File

@ -2238,6 +2238,7 @@ _PyStaticCode_Dealloc(PyCodeObject *co)
Py_CLEAR(co->_co_cached->_co_freevars);
Py_CLEAR(co->_co_cached->_co_varnames);
PyMem_Free(co->_co_cached);
co->_co_cached = NULL;
}
co->co_extra = NULL;
if (co->co_weakreflist != NULL) {

View File

@ -651,6 +651,8 @@ add_load_fast_null_checks(PyCodeObject *co)
Py_CLEAR(co->_co_cached->_co_cellvars);
Py_CLEAR(co->_co_cached->_co_freevars);
Py_CLEAR(co->_co_cached->_co_varnames);
PyMem_Free(co->_co_cached);
co->_co_cached = NULL;
}
}