summaryrefslogtreecommitdiff
path: root/Python/codecs.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2000-06-28 22:07:35 +0000
committerGuido van Rossum <guido@python.org>2000-06-28 22:07:35 +0000
commita53d534fb8dfc476652e45c58b795bf021ea586a (patch)
tree6b29848cddf7fe5e95c712b62b5fd71706cf9225 /Python/codecs.c
parentc457c777956d0ff9d689841cbddb8e7770605d42 (diff)
downloadcpython-a53d534fb8dfc476652e45c58b795bf021ea586a.tar.gz
Trent Mick's Win64 changes: size_t vs. int or long; also some overflow
tests.
Diffstat (limited to 'Python/codecs.c')
-rw-r--r--Python/codecs.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/Python/codecs.c b/Python/codecs.c
index 5e01ccae13..ceff376a23 100644
--- a/Python/codecs.c
+++ b/Python/codecs.c
@@ -83,11 +83,16 @@ static
PyObject *normalizestring(const char *string)
{
register int i;
- int len = strlen(string);
+ size_t len = strlen(string);
char *p;
PyObject *v;
- v = PyString_FromStringAndSize(NULL, len);
+ if (len > INT_MAX) {
+ PyErr_SetString(PyExc_OverflowError, "string is too large");
+ return NULL;
+ }
+
+ v = PyString_FromStringAndSize(NULL, (int)len);
if (v == NULL)
return NULL;
p = PyString_AS_STRING(v);