Mercurial > cpython-lru_cache-weakref
diff Modules/_tkinter.c @ 44444:036b00dc9767 2.5
Fix bug #1301 -- a bad assert in _tkinter.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 03 Jan 2008 23:52:04 +0000 |
| parents | 6a8f01660a3b |
| children | 787b969d37f0 |
line wrap: on
line diff
--- a/Modules/_tkinter.c Thu Jan 03 19:08:15 2008 +0000 +++ b/Modules/_tkinter.c Thu Jan 03 23:52:04 2008 +0000 @@ -936,10 +936,12 @@ /* 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;
