mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
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.
This commit is contained in:
parent
20b15bbc56
commit
d1c5510b99
1 changed files with 10 additions and 3 deletions
|
@ -1884,11 +1884,14 @@ Tkapp_SplitList(PyObject *self, PyObject *args)
|
||||||
if (!PyArg_ParseTuple(args, "et:splitlist", "utf-8", &list))
|
if (!PyArg_ParseTuple(args, "et:splitlist", "utf-8", &list))
|
||||||
return NULL;
|
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);
|
return Tkinter_Error(self);
|
||||||
|
}
|
||||||
|
|
||||||
if (!(v = PyTuple_New(argc)))
|
if (!(v = PyTuple_New(argc)))
|
||||||
return NULL;
|
goto finally;
|
||||||
|
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
PyObject *s = PyString_FromString(argv[i]);
|
PyObject *s = PyString_FromString(argv[i]);
|
||||||
|
@ -1901,12 +1904,14 @@ Tkapp_SplitList(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
ckfree(FREECAST argv);
|
ckfree(FREECAST argv);
|
||||||
|
PyMem_Free(list);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
Tkapp_Split(PyObject *self, PyObject *args)
|
Tkapp_Split(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
|
PyObject *v;
|
||||||
char *list;
|
char *list;
|
||||||
|
|
||||||
if (PyTuple_Size(args) == 1) {
|
if (PyTuple_Size(args) == 1) {
|
||||||
|
@ -1918,7 +1923,9 @@ Tkapp_Split(PyObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
if (!PyArg_ParseTuple(args, "et:split", "utf-8", &list))
|
if (!PyArg_ParseTuple(args, "et:split", "utf-8", &list))
|
||||||
return NULL;
|
return NULL;
|
||||||
return Split(list);
|
v = Split(list);
|
||||||
|
PyMem_Free(list);
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue