Mercurial > cpython-lru_cache-weakref
diff Objects/unicodeobject.c @ 84281:f8ede55cf92b 3.3
Issue #18184: PyUnicode_FromFormat() and PyUnicode_FromFormatV() now raise
OverflowError when an argument of %c format is out of range.
| author | Serhiy Storchaka <storchaka@gmail.com> |
|---|---|
| date | Sun, 23 Jun 2013 20:12:14 +0300 |
| parents | 89b106d298a9 |
| children | b719f041f849 42def600210e |
line wrap: on
line diff
--- a/Objects/unicodeobject.c Sun Jun 23 16:10:29 2013 +0200 +++ b/Objects/unicodeobject.c Sun Jun 23 20:12:14 2013 +0300 @@ -2489,8 +2489,13 @@ switch (*f) { case 'c': { - Py_UCS4 ordinal = va_arg(count, int); - maxchar = Py_MAX(maxchar, ordinal); + int ordinal = va_arg(count, int); + if (ordinal < 0 || ordinal > MAX_UNICODE) { + PyErr_SetString(PyExc_OverflowError, + "%c arg not in range(0x110000)"); + goto fail; + } + maxchar = Py_MAX(maxchar, (Py_UCS4)ordinal); n++; break; }
