diff options
author | Ken Jin <kenjin@python.org> | 2022-10-11 15:11:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-11 15:11:46 (GMT) |
commit | 7ec2e279fea3b340f642cff888bfa45368f5ded0 (patch) | |
tree | a677cc56debb4a2f8a7d6916335a6edfa4737418 | |
parent | 4067c6d7fe9b0b266367aafa8cde71e2761cb764 (diff) | |
download | cpython-7ec2e279fea3b340f642cff888bfa45368f5ded0.zip cpython-7ec2e279fea3b340f642cff888bfa45368f5ded0.tar.gz cpython-7ec2e279fea3b340f642cff888bfa45368f5ded0.tar.bz2 |
gh-95756: Free and NULL-out code caches when needed (GH-98181)
-rw-r--r-- | Objects/codeobject.c | 1 | ||||
-rw-r--r-- | Objects/frameobject.c | 2 |
2 files changed, 3 insertions, 0 deletions
diff --git a/Objects/codeobject.c b/Objects/codeobject.c index 7a0080c..8920b1d 100644 --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -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) { diff --git a/Objects/frameobject.c b/Objects/frameobject.c index bd1608e..8b4494a 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -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; } } |