mirror of
https://github.com/python/cpython.git
synced 2025-10-21 14:12:27 +00:00
PyUnicode_FindChar() raises a IndexError on invalid index
This commit is contained in:
parent
bc603d12b7
commit
267aa24365
1 changed files with 4 additions and 0 deletions
|
@ -8089,6 +8089,10 @@ PyUnicode_FindChar(PyObject *str, Py_UCS4 ch,
|
||||||
int kind;
|
int kind;
|
||||||
if (PyUnicode_READY(str) == -1)
|
if (PyUnicode_READY(str) == -1)
|
||||||
return -2;
|
return -2;
|
||||||
|
if (start < 0 || end < 0) {
|
||||||
|
PyErr_SetString(PyExc_IndexError, "string index out of range");
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
if (end > PyUnicode_GET_LENGTH(str))
|
if (end > PyUnicode_GET_LENGTH(str))
|
||||||
end = PyUnicode_GET_LENGTH(str);
|
end = PyUnicode_GET_LENGTH(str);
|
||||||
kind = PyUnicode_KIND(str);
|
kind = PyUnicode_KIND(str);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue