Skip to content

Commit 7ec2e27

Browse files
gh-95756: Free and NULL-out code caches when needed (GH-98181)
1 parent 4067c6d commit 7ec2e27

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

Objects/codeobject.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2238,6 +2238,7 @@ _PyStaticCode_Dealloc(PyCodeObject *co)
22382238
Py_CLEAR(co->_co_cached->_co_freevars);
22392239
Py_CLEAR(co->_co_cached->_co_varnames);
22402240
PyMem_Free(co->_co_cached);
2241+
co->_co_cached = NULL;
22412242
}
22422243
co->co_extra = NULL;
22432244
if (co->co_weakreflist != NULL) {

Objects/frameobject.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,8 @@ add_load_fast_null_checks(PyCodeObject *co)
651651
Py_CLEAR(co->_co_cached->_co_cellvars);
652652
Py_CLEAR(co->_co_cached->_co_freevars);
653653
Py_CLEAR(co->_co_cached->_co_varnames);
654+
PyMem_Free(co->_co_cached);
655+
co->_co_cached = NULL;
654656
}
655657
}
656658

0 commit comments

Comments
 (0)