[Python-checkins] cpython: Issue #11826: Fix memory leak in atexitmodule.

stefan.krah python-checkins at python.org
Tue Mar 27 11:50:29 CEST 2012


http://hg.python.org/cpython/rev/7c48bb929e6e
changeset:   75968:7c48bb929e6e
parent:      75966:b69c6e092696
user:        Stefan Krah <skrah at bytereef.org>
date:        Tue Mar 27 11:49:21 2012 +0200
summary:
  Issue #11826: Fix memory leak in atexitmodule.

files:
  Modules/atexitmodule.c |  10 +++++++++-
  1 files changed, 9 insertions(+), 1 deletions(-)


diff --git a/Modules/atexitmodule.c b/Modules/atexitmodule.c
--- a/Modules/atexitmodule.c
+++ b/Modules/atexitmodule.c
@@ -211,6 +211,14 @@
     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 @@
 	NULL,
 	NULL,
 	NULL,
-	NULL
+	(freefunc)atexit_free
 };
 
 PyMODINIT_FUNC

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list