mirror of
https://github.com/python/cpython.git
synced 2025-10-06 15:11:58 +00:00
[3.6] bpo-31675: Fix memory leaks in Tkinter's methods splitlist() and split() (GH-3866) (#3874)
when pass a string larger than 2 GiB.
Decrease memory requirements for Tcl's bigmem tests.
(cherry picked from commit 27c623c845
)
This commit is contained in:
parent
fcc832a4fa
commit
a65b2420f6
3 changed files with 45 additions and 23 deletions
|
@ -2291,7 +2291,11 @@ _tkinter_tkapp_splitlist(TkappObject *self, PyObject *arg)
|
|||
if (!PyArg_Parse(arg, "et:splitlist", "utf-8", &list))
|
||||
return NULL;
|
||||
|
||||
CHECK_STRING_LENGTH(list);
|
||||
if (strlen(list) >= INT_MAX) {
|
||||
PyErr_SetString(PyExc_OverflowError, "string is too long");
|
||||
PyMem_Free(list);
|
||||
return NULL;
|
||||
}
|
||||
if (Tcl_SplitList(Tkapp_Interp(self), list,
|
||||
&argc, &argv) == TCL_ERROR) {
|
||||
PyMem_Free(list);
|
||||
|
@ -2362,7 +2366,11 @@ _tkinter_tkapp_split(TkappObject *self, PyObject *arg)
|
|||
|
||||
if (!PyArg_Parse(arg, "et:split", "utf-8", &list))
|
||||
return NULL;
|
||||
CHECK_STRING_LENGTH(list);
|
||||
if (strlen(list) >= INT_MAX) {
|
||||
PyErr_SetString(PyExc_OverflowError, "string is too long");
|
||||
PyMem_Free(list);
|
||||
return NULL;
|
||||
}
|
||||
v = Split(list);
|
||||
PyMem_Free(list);
|
||||
return v;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue