summaryrefslogtreecommitdiff
path: root/Modules/_codecsmodule.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2012-10-09 11:16:26 -0400
committerBenjamin Peterson <benjamin@python.org>2012-10-09 11:16:26 -0400
commit455fa0a314b7f7edd0c8554b12a65267ff1e2e5b (patch)
treea4db0395d8674c1e3c4119f0edccf72307b34e49 /Modules/_codecsmodule.c
parentb29614e047110f4d9af993a6cdec4e3fb7ef9738 (diff)
parent831893a68ec7114c1fc9c8e36b9159f5c1db50c7 (diff)
downloadcpython-git-455fa0a314b7f7edd0c8554b12a65267ff1e2e5b.tar.gz
merge heads
Diffstat (limited to 'Modules/_codecsmodule.c')
-rw-r--r--Modules/_codecsmodule.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Modules/_codecsmodule.c b/Modules/_codecsmodule.c
index 7818f9a42f..40037b1dc6 100644
--- a/Modules/_codecsmodule.c
+++ b/Modules/_codecsmodule.c
@@ -177,12 +177,12 @@ escape_encode(PyObject *self,
return NULL;
size = PyBytes_GET_SIZE(str);
- newsize = 4*size;
- if (newsize > PY_SSIZE_T_MAX || newsize / 4 != size) {
+ if (size > PY_SSIZE_T_MAX / 4) {
PyErr_SetString(PyExc_OverflowError,
"string is too large to encode");
return NULL;
}
+ newsize = 4*size;
v = PyBytes_FromStringAndSize(NULL, newsize);
if (v == NULL) {