changeset: 93074:f963cc1f96cf branch: 3.3 parent: 93071:6a91e616485a user: Benjamin Peterson date: Wed Oct 15 12:17:21 2014 -0400 files: Objects/unicodeobject.c description: it suffices to check for PY_SSIZE_T_MAX overflow (#22643) diff -r 6a91e616485a -r f963cc1f96cf Objects/unicodeobject.c --- a/Objects/unicodeobject.c Wed Oct 15 11:51:05 2014 -0400 +++ b/Objects/unicodeobject.c Wed Oct 15 12:17:21 2014 -0400 @@ -9484,12 +9484,11 @@ kind = PyUnicode_KIND(self); data = PyUnicode_DATA(self); length = PyUnicode_GET_LENGTH(self); - if (length > PY_SSIZE_T_MAX / 3 || - length > PY_SIZE_MAX / (3 * sizeof(Py_UCS4))) { + if (length > PY_SSIZE_T_MAX / (3 * sizeof(Py_UCS4))) { PyErr_SetString(PyExc_OverflowError, "string is too long"); return NULL; } - tmp = PyMem_MALLOC(sizeof(Py_UCS4) * 3 * (size_t)length); + tmp = PyMem_MALLOC(sizeof(Py_UCS4) * 3 * length); if (tmp == NULL) return PyErr_NoMemory(); newlength = perform(kind, data, length, tmp, &maxchar);