8000 Fix leaks in Python-ast.c (#16127) · python/cpython@0247e80 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0247e80

Browse files
eduardo-elizondoDinoV
authored andcommitted
Fix leaks in Python-ast.c (#16127)
1 parent 279f446 commit 0247e80

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Parser/asdl_c.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,9 +638,13 @@ def visitModule(self, mod):
638638
ast_dealloc(AST_object *self)
639639
{
640640
/* bpo-31095: UnTrack is needed before calling any callbacks */
641+
PyTypeObject *tp = Py_TYPE(self);
641642
PyObject_GC_UnTrack(self);
642643
Py_CLEAR(self->dict);
643-
Py_TYPE(self)->tp_free(self);
644+
freefunc free_func = PyType_GetSlot(tp, Py_tp_free);
645+
assert(free_func != NULL);
646+
free_func(self);
647+
Py_DECREF(tp);
644648
}
645649
646650
static int

Python/Python-ast.c

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
0