diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-09-11 07:56:59 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-09-11 07:56:59 (GMT) |
commit | 17c01785ee12331fb8cf782ded90a5eaed0b88e1 (patch) | |
tree | 66d800a2cf8a18d099d99a03c039cdf84b5d5710 | |
parent | 1c09c0ea1107a8fbb22c949235a0950b9a98e252 (diff) | |
download | cpython-17c01785ee12331fb8cf782ded90a5eaed0b88e1.zip cpython-17c01785ee12331fb8cf782ded90a5eaed0b88e1.tar.gz cpython-17c01785ee12331fb8cf782ded90a5eaed0b88e1.tar.bz2 |
Issue #21951: Fixed a crash in Tkinter on AIX when called Tcl command with
empty string or tuple argument.
On some platforms Tcl memory allocator returns NULL when allocating zero-sized
block of memory.
-rw-r--r-- | Lib/test/test_tcl.py | 3 | ||||
-rw-r--r-- | Misc/NEWS | 3 | ||||
-rw-r--r-- | Modules/_tkinter.c | 4 |
3 files changed, 9 insertions, 1 deletions
diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py index d627034..5836989 100644 --- a/Lib/test/test_tcl.py +++ b/Lib/test/test_tcl.py @@ -429,7 +429,6 @@ class TclTest(unittest.TestCase): self.assertEqual(passValue((1, '2', (3.4,))), (1, '2', (3.4,)) if self.wantobjects else '1 2 3.4') - @unittest.skipIf(sys.platform.startswith("aix"), 'Issue #21951: crashes on AIX') def test_user_command(self): result = [] def testfunc(arg): @@ -456,9 +455,11 @@ class TclTest(unittest.TestCase): check('string') check('string\xbd') check('string\xe2\x82\xac', u'string\u20ac') + check('') check(u'string') check(u'string\xbd') check(u'string\u20ac') + check(u'') check('str\xc0\x80ing', u'str\x00ing') check('str\xc0\x80ing\xe2\x82\xac', u'str\x00ing\u20ac') check(u'str\x00ing') @@ -22,6 +22,9 @@ Core and Builtins Library ------- +- Issue #21951: Fixed a crash in Tkinter on AIX when called Tcl command with + empty string or tuple argument. + - Issue #21951: Tkinter now most likely raises MemoryError instead of crash if the memory allocation fails. diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c index d0a4464..acc0110 100644 --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -1052,6 +1052,8 @@ AsObj(PyObject *value) Py_ssize_t size, i; size = PyTuple_Size(value); + if (size == 0) + return Tcl_NewListObj(0, NULL); if (!CHECK_SIZE(size, sizeof(Tcl_Obj *))) { PyErr_SetString(PyExc_OverflowError, "tuple is too long"); return NULL; @@ -1075,6 +1077,8 @@ AsObj(PyObject *value) Tcl_UniChar *outbuf = NULL; Py_ssize_t i; size_t allocsize; + if (size == 0) + return Tcl_NewUnicodeObj((const void *)"", 0); if (!CHECK_SIZE(size, sizeof(Tcl_UniChar))) { PyErr_SetString(PyExc_OverflowError, "string is too long"); return NULL; |