summaryrefslogtreecommitdiffstats
path: root/Objects/codeobject.c
diff options
context:
space:
mode:
authorKumar Aditya <59607654+kumaraditya303@users.noreply.github.com>2022-01-27 13:03:47 (GMT)
committerGitHub <noreply@github.com>2022-01-27 13:03:47 (GMT)
commitc7f810b34d91a5c2fbe0a8385562015d2dd961f2 (patch)
tree0fcbd6901e212f47e1054a862af4d8ec571ee7c2 /Objects/codeobject.c
parentecfacc362dd7fef7715dcd94f2e2ca6c622ef115 (diff)
downloadcpython-c7f810b34d91a5c2fbe0a8385562015d2dd961f2.zip
cpython-c7f810b34d91a5c2fbe0a8385562015d2dd961f2.tar.gz
cpython-c7f810b34d91a5c2fbe0a8385562015d2dd961f2.tar.bz2
bpo-46476: Fix memory leak in code objects generated by deepfreeze (GH-30853)
Add _Py_Deepfreeze_Fini() and _PyStaticCode_Dealloc() functions.
Diffstat (limited to 'Objects/codeobject.c')
-rw-r--r--Objects/codeobject.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/Objects/codeobject.c b/Objects/codeobject.c
index a413b18..f983d66 100644
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -1906,3 +1906,18 @@ _PyCode_ConstantKey(PyObject *op)
}
return key;
}
+
+void
+_PyStaticCode_Dealloc(PyCodeObject *co, _Py_CODEUNIT *firstinstr)
+{
+ PyMem_Free(co->co_quickened);
+ co->co_quickened = NULL;
+ PyMem_Free(co->co_extra);
+ co->co_extra = NULL;
+ co->co_firstinstr = firstinstr;
+ if (co->co_weakreflist != NULL) {
+ PyObject_ClearWeakRefs((PyObject *)co);
+ co->co_weakreflist = NULL;
+ }
+ co->co_warmup = QUICKENING_INITIAL_WARMUP_VALUE;
+}