mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
Fix leaks in Python-ast.c (#16127)
This commit is contained in:
parent
279f44678c
commit
0247e80f3c
2 changed files with 10 additions and 2 deletions
|
@ -638,9 +638,13 @@ static void
|
||||||
ast_dealloc(AST_object *self)
|
ast_dealloc(AST_object *self)
|
||||||
{
|
{
|
||||||
/* bpo-31095: UnTrack is needed before calling any callbacks */
|
/* bpo-31095: UnTrack is needed before calling any callbacks */
|
||||||
|
PyTypeObject *tp = Py_TYPE(self);
|
||||||
PyObject_GC_UnTrack(self);
|
PyObject_GC_UnTrack(self);
|
||||||
Py_CLEAR(self->dict);
|
Py_CLEAR(self->dict);
|
||||||
Py_TYPE(self)->tp_free(self);
|
freefunc free_func = PyType_GetSlot(tp, Py_tp_free);
|
||||||
|
assert(free_func != NULL);
|
||||||
|
free_func(self);
|
||||||
|
Py_DECREF(tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
6
Python/Python-ast.c
generated
6
Python/Python-ast.c
generated
|
@ -1130,9 +1130,13 @@ static void
|
||||||
ast_dealloc(AST_object *self)
|
ast_dealloc(AST_object *self)
|
||||||
{
|
{
|
||||||
/* bpo-31095: UnTrack is needed before calling any callbacks */
|
/* bpo-31095: UnTrack is needed before calling any callbacks */
|
||||||
|
PyTypeObject *tp = Py_TYPE(self);
|
||||||
PyObject_GC_UnTrack(self);
|
PyObject_GC_UnTrack(self);
|
||||||
Py_CLEAR(self->dict);
|
Py_CLEAR(self->dict);
|
||||||
Py_TYPE(self)->tp_free(self);
|
freefunc free_func = PyType_GetSlot(tp, Py_tp_free);
|
||||||
|
assert(free_func != NULL);
|
||||||
|
free_func(self);
|
||||||
|
Py_DECREF(tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue