diff options
Diffstat (limited to 'Python/codecs.c')
-rw-r--r-- | Python/codecs.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Python/codecs.c b/Python/codecs.c index 5e01cca..ceff376 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); |