Skip to content

Commit 650365b

Browse files
author
Stefan Krah
committed
Issue #11826: Fix memory leak in atexitmodule.
1 parent dc5a4e1 commit 650365b

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

Modules/atexitmodule.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,14 @@ atexit_clear(PyObject *self, PyObject *unused)
211211
Py_RETURN_NONE;
212212
}
213213

214+
static void
215+
atexit_free(PyObject *m)
216+
{
217+
atexitmodule_state *modstate;
218+
modstate = GET_ATEXIT_STATE(m);
219+
PyMem_Free(modstate->atexit_callbacks);
220+
}
221+
214222
PyDoc_STRVAR(atexit_unregister__doc__,
215223
"unregister(func) -> None\n\
216224
\n\
@@ -275,7 +283,7 @@ static struct PyModuleDef atexitmodule = {
275283
NULL,
276284
NULL,
277285
NULL,
278-
NULL
286+
(freefunc)atexit_free
279287
};
280288

281289
PyMODINIT_FUNC

0 commit comments

Comments
 (0)