diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-10-03 19:39:55 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-03 19:39:55 (GMT) |
commit | 27c623c845dd6e4b8e1782666ca3a956636da266 (patch) | |
tree | 34f5e36867c4bb5431c77e77c3b7f5cd0002cb99 /Modules/_tkinter.c | |
parent | 929b40a601db868530d6beaafb3256822103a7fb (diff) | |
download | cpython-27c623c845dd6e4b8e1782666ca3a956636da266.zip cpython-27c623c845dd6e4b8e1782666ca3a956636da266.tar.gz cpython-27c623c845dd6e4b8e1782666ca3a956636da266.tar.bz2 |
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.
Diffstat (limited to 'Modules/_tkinter.c')
-rw-r--r-- | Modules/_tkinter.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c index 07ebadd..005214e 100644 --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -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; |