mirror of
https://github.com/python/cpython.git
synced 2025-12-15 21:44:50 +00:00
bpo-31675: Fix memory leaks in Tkinter's methods splitlist() and split() (#3866)
when pass a string larger than 2 GiB. Decrease memory requirements for Tcl's bigmem tests.
This commit is contained in:
parent
929b40a601
commit
27c623c845
3 changed files with 45 additions and 23 deletions
|
|
@ -2257,7 +2257,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);
|
||||
|
|
@ -2328,7 +2332,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