Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 267aa24

Browse files
author
Victor Stinner
committed
PyUnicode_FindChar() raises a IndexError on invalid index
1 parent bc603d1 commit 267aa24

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

Objects/unicodeobject.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8089,6 +8089,10 @@ PyUnicode_FindChar(PyObject *str, Py_UCS4 ch,
80898089
int kind;
80908090
if (PyUnicode_READY(str) == -1)
80918091
return -2;
8092+
if (start < 0 || end < 0) {
8093+
PyErr_SetString(PyExc_IndexError, "string index out of range");
8094+
return -2;
8095+
}
80928096
if (end > PyUnicode_GET_LENGTH(str))
80938097
end = PyUnicode_GET_LENGTH(str);
80948098
kind = PyUnicode_KIND(str);

0 commit comments

Comments
 (0)