]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-95756: Free and NULL-out code caches when needed (GH-98181)
authorKen Jin <kenjin@python.org>
Tue, 11 Oct 2022 15:11:46 +0000 (23:11 +0800)
committerGitHub <noreply@github.com>
Tue, 11 Oct 2022 15:11:46 +0000 (23:11 +0800)
Objects/codeobject.c
Objects/frameobject.c

index 7a0080c08c7b54732c2c85de523e39ea954352ed..8920b1db2cadb7d236133f3acbb5cc87dcd9df61 100644 (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) {
index bd1608e0d75a6e3e5e92d37d1bd5fedfcb55ff73..8b4494a5fe82fd88d533a60672a39cbb85e1249c 100644 (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;
     }
 }