mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
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.
This commit is contained in:
parent
0794088379
commit
abf68ce164
3 changed files with 9 additions and 1 deletions
|
|
@ -416,7 +416,6 @@ class TclTest(unittest.TestCase):
|
||||||
self.assertEqual(passValue((1, '2', (3.4,))),
|
self.assertEqual(passValue((1, '2', (3.4,))),
|
||||||
(1, '2', (3.4,)) if self.wantobjects else '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):
|
def test_user_command(self):
|
||||||
result = None
|
result = None
|
||||||
def testfunc(arg):
|
def testfunc(arg):
|
||||||
|
|
@ -444,9 +443,11 @@ class TclTest(unittest.TestCase):
|
||||||
check('string')
|
check('string')
|
||||||
check('string\xbd')
|
check('string\xbd')
|
||||||
check('string\u20ac')
|
check('string\u20ac')
|
||||||
|
check('')
|
||||||
check(b'string', 'string')
|
check(b'string', 'string')
|
||||||
check(b'string\xe2\x82\xac', 'string\xe2\x82\xac')
|
check(b'string\xe2\x82\xac', 'string\xe2\x82\xac')
|
||||||
check(b'string\xbd', 'string\xbd')
|
check(b'string\xbd', 'string\xbd')
|
||||||
|
check(b'', '')
|
||||||
check('str\x00ing')
|
check('str\x00ing')
|
||||||
check('str\x00ing\xbd')
|
check('str\x00ing\xbd')
|
||||||
check('str\x00ing\u20ac')
|
check('str\x00ing\u20ac')
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,9 @@ Core and Builtins
|
||||||
Library
|
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
|
- Issue #21951: Tkinter now most likely raises MemoryError instead of crash
|
||||||
if the memory allocation fails.
|
if the memory allocation fails.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -899,6 +899,8 @@ AsObj(PyObject *value)
|
||||||
Py_ssize_t size, i;
|
Py_ssize_t size, i;
|
||||||
|
|
||||||
size = PyTuple_Size(value);
|
size = PyTuple_Size(value);
|
||||||
|
if (size == 0)
|
||||||
|
return Tcl_NewListObj(0, NULL);
|
||||||
if (!CHECK_SIZE(size, sizeof(Tcl_Obj *))) {
|
if (!CHECK_SIZE(size, sizeof(Tcl_Obj *))) {
|
||||||
PyErr_SetString(PyExc_OverflowError, "tuple is too long");
|
PyErr_SetString(PyExc_OverflowError, "tuple is too long");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -925,6 +927,8 @@ AsObj(PyObject *value)
|
||||||
|
|
||||||
inbuf = PyUnicode_DATA(value);
|
inbuf = PyUnicode_DATA(value);
|
||||||
size = PyUnicode_GET_LENGTH(value);
|
size = PyUnicode_GET_LENGTH(value);
|
||||||
|
if (size == 0)
|
||||||
|
return Tcl_NewUnicodeObj((const void *)"", 0);
|
||||||
if (!CHECK_SIZE(size, sizeof(Tcl_UniChar))) {
|
if (!CHECK_SIZE(size, sizeof(Tcl_UniChar))) {
|
||||||
PyErr_SetString(PyExc_OverflowError, "string is too long");
|
PyErr_SetString(PyExc_OverflowError, "string is too long");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue