summaryrefslogtreecommitdiffstats
path: root/Modules/atexitmodule.c
diff options
context:
space:
mode:
authorStefan Krah <skrah@bytereef.org>2012-03-27 09:49:21 (GMT)
committerStefan Krah <skrah@bytereef.org>2012-03-27 09:49:21 (GMT)
commit650365b1633891fb8281b375e54ae13201e05a73 (patch)
tree6a5bf9777cbd52bf4dfd923c18fc3d7117046e45 /Modules/atexitmodule.c
parentdc5a4e16118caeac1168b6f47e580d388f101bfd (diff)
downloadcpython-650365b1633891fb8281b375e54ae13201e05a73.zip
cpython-650365b1633891fb8281b375e54ae13201e05a73.tar.gz
cpython-650365b1633891fb8281b375e54ae13201e05a73.tar.bz2
Issue #11826: Fix memory leak in atexitmodule.
Diffstat (limited to 'Modules/atexitmodule.c')
-rw-r--r--Modules/atexitmodule.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/Modules/atexitmodule.c b/Modules/atexitmodule.c
index 1ee7ead..f68d804 100644
--- a/Modules/atexitmodule.c
+++ b/Modules/atexitmodule.c
@@ -211,6 +211,14 @@ atexit_clear(PyObject *self, PyObject *unused)
Py_RETURN_NONE;
}
+static void
+atexit_free(PyObject *m)
+{
+ atexitmodule_state *modstate;
+ modstate = GET_ATEXIT_STATE(m);
+ PyMem_Free(modstate->atexit_callbacks);
+}
+
PyDoc_STRVAR(atexit_unregister__doc__,
"unregister(func) -> None\n\
\n\
@@ -275,7 +283,7 @@ static struct PyModuleDef atexitmodule = {
NULL,
NULL,
NULL,
- NULL
+ (freefunc)atexit_free
};
PyMODINIT_FUNC