From 076d9eef7bb49eaf0381a6e6f6f5ea71167cd504 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Thu, 3 Jan 2008 23:54:04 +0000 Subject: Bug #1301: fixed a bad assert in _tkinter. --- Misc/NEWS | 2 ++ Modules/_tkinter.c | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS index 2a4b722..5ea88f2 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -907,6 +907,8 @@ Library Extension Modules ----------------- +- Bug #1301: Bad assert in _tkinter fixed. + - Added bdist_wininst executable for VS 2008. - Bug #1604: collections.deque.__init__(iterable) now clears any prior contents 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; -- cgit v0.12