Mercurial > cpython-lru_cache-weakref
diff Python/codecs.c @ 13096:8c8de5b736dc legacy-trunk
Trent Mick's Win64 changes: size_t vs. int or long; also some overflow
tests.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Wed, 28 Jun 2000 22:07:35 +0000 |
| parents | 2a53f5dc0590 |
| children | cb928d926f27 |
line wrap: on
line diff
--- a/Python/codecs.c Wed Jun 28 22:05:44 2000 +0000 +++ b/Python/codecs.c Wed Jun 28 22:07:35 2000 +0000 @@ -83,11 +83,16 @@ 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);
