summaryrefslogtreecommitdiff
path: root/Modules/_codecsmodule.c
diff options
context:
space:
mode:
authorMark Dickinson <mdickinson@enthought.com>2012-10-06 18:04:49 +0100
committerMark Dickinson <mdickinson@enthought.com>2012-10-06 18:04:49 +0100
commitc04ddff290fc203d05b75c8569b748525fb76b5b (patch)
tree184849e76ebe965016c2737939f9eaa0dfb900ee /Modules/_codecsmodule.c
parenta2028733ef072740921017e544d29d191fdb2c9c (diff)
downloadcpython-git-c04ddff290fc203d05b75c8569b748525fb76b5b.tar.gz
Issue #16096: Fix several occurrences of potential signed integer overflow. Thanks Serhiy Storchaka.
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) {