diff options
| author | Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> | 2022-01-27 18:33:47 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-27 14:03:47 +0100 |
| commit | c7f810b34d91a5c2fbe0a8385562015d2dd961f2 (patch) | |
| tree | 0fcbd6901e212f47e1054a862af4d8ec571ee7c2 /Objects/codeobject.c | |
| parent | ecfacc362dd7fef7715dcd94f2e2ca6c622ef115 (diff) | |
| download | cpython-git-c7f810b34d91a5c2fbe0a8385562015d2dd961f2.tar.gz | |
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.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Objects/codeobject.c b/Objects/codeobject.c index a413b183be..f983d66db0 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; +} |
