From d1c5510b997a1cf12dcc2619ba7b8663df5f4009 Mon Sep 17 00:00:00 2001 From: Neal Norwitz Date: Thu, 29 May 2003 00:17:03 +0000 Subject: Fix SF #745055, Memory leak in _tkinter.c/Tkapp_SplitList() Also fix a memory leak in Tkapp_Split. This needs to be backported. I'll leave it up to Barry whether this is for 2.2.3 or 2.2.4. --- Modules/_tkinter.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c index fbc6ec1..5851372 100644 --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -1884,11 +1884,14 @@ Tkapp_SplitList(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "et:splitlist", "utf-8", &list)) return NULL; - if (Tcl_SplitList(Tkapp_Interp(self), list, &argc, &argv) == TCL_ERROR) + if (Tcl_SplitList(Tkapp_Interp(self), list, + &argc, &argv) == TCL_ERROR) { + PyMem_Free(list); return Tkinter_Error(self); + } if (!(v = PyTuple_New(argc))) - return NULL; + goto finally; for (i = 0; i < argc; i++) { PyObject *s = PyString_FromString(argv[i]); @@ -1901,12 +1904,14 @@ Tkapp_SplitList(PyObject *self, PyObject *args) finally: ckfree(FREECAST argv); + PyMem_Free(list); return v; } static PyObject * Tkapp_Split(PyObject *self, PyObject *args) { + PyObject *v; char *list; if (PyTuple_Size(args) == 1) { @@ -1918,7 +1923,9 @@ Tkapp_Split(PyObject *self, PyObject *args) } if (!PyArg_ParseTuple(args, "et:split", "utf-8", &list)) return NULL; - return Split(list); + v = Split(list); + PyMem_Free(list); + return v; } static PyObject * -- cgit v0.12