summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2014-10-15 16:17:21 (GMT)
committerBenjamin Peterson <benjamin@python.org>2014-10-15 16:17:21 (GMT)
commit1e211ff10dbab6da8fc7170bd09cd6fdaeec9dde (patch)
treef3865e57bdd3715c7466a8ac5c4be46f2492c213 /Objects
parentc0e64f5027a2d07976027447b6d1ef464a2dc158 (diff)
downloadcpython-1e211ff10dbab6da8fc7170bd09cd6fdaeec9dde.zip
cpython-1e211ff10dbab6da8fc7170bd09cd6fdaeec9dde.tar.gz
cpython-1e211ff10dbab6da8fc7170bd09cd6fdaeec9dde.tar.bz2
it suffices to check for PY_SSIZE_T_MAX overflow (#22643)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 2a10eec..8eb2dd2 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -9484,12 +9484,11 @@ case_operation(PyObject *self,
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);