]> granicus.if.org Git - python/commitdiff
Issue #11826: Fix memory leak in atexitmodule.
authorStefan Krah <skrah@bytereef.org>
Tue, 27 Mar 2012 09:49:21 +0000 (11:49 +0200)
committerStefan Krah <skrah@bytereef.org>
Tue, 27 Mar 2012 09:49:21 +0000 (11:49 +0200)
Modules/atexitmodule.c

index 1ee7ead05f72cf2b896fb848add5d93caf343e4b..f68d8047ed7ee88f89fb98642893b98dedff1cf7 100644 (file)
@@ -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