mirror of
https://github.com/python/cpython.git
synced 2025-07-24 19:54:21 +00:00
Issue #18184: PyUnicode_FromFormat() and PyUnicode_FromFormatV() now raise
OverflowError when an argument of %c format is out of range.
This commit is contained in:
parent
36a7e4f74a
commit
8eeae2126c
3 changed files with 12 additions and 2 deletions
|
@ -2489,8 +2489,13 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
|
|||
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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue