diff options
author | Guido van Rossum <guido@python.org> | 2008-01-03 23:54:04 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2008-01-03 23:54:04 (GMT) |
commit | 076d9eef7bb49eaf0381a6e6f6f5ea71167cd504 (patch) | |
tree | ce307a1ccfc064e232cdf5d75bde742ba393fefb /Modules | |
parent | eebb79cc690e8ab02cb7f630cfbc046df2c0f4da (diff) | |
download | cpython-076d9eef7bb49eaf0381a6e6f6f5ea71167cd504.zip cpython-076d9eef7bb49eaf0381a6e6f6f5ea71167cd504.tar.gz cpython-076d9eef7bb49eaf0381a6e6f6f5ea71167cd504.tar.bz2 |
Bug #1301: fixed a bad assert in _tkinter.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_tkinter.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c index 3cef4e7..4308773 100644 --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -936,10 +936,12 @@ AsObj(PyObject *value) /* This #ifdef assumes that Tcl uses UCS-2. See TCL_UTF_MAX test above. */ #if defined(Py_UNICODE_WIDE) && TCL_UTF_MAX == 3 - Tcl_UniChar *outbuf; + Tcl_UniChar *outbuf = NULL; Py_ssize_t i; - assert(size < size * sizeof(Tcl_UniChar)); - outbuf = (Tcl_UniChar*)ckalloc(size * sizeof(Tcl_UniChar)); + size_t allocsize = ((size_t)size) * sizeof(Tcl_UniChar); + if (allocsize >= size) + outbuf = (Tcl_UniChar*)ckalloc(allocsize); + /* Else overflow occurred, and we take the next exit */ if (!outbuf) { PyErr_NoMemory(); return NULL; |