Skip to content

Commit

Permalink
gh-95756: Free and NULL-out code caches when needed (GH-98181)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fidget-Spinner authored Oct 11, 2022
1 parent 4067c6d commit 7ec2e27
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions Objects/codeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions Objects/frameobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 7ec2e27

Please sign in to comment.