]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
PyUnicode_FindChar() raises a IndexError on invalid index
authorVictor Stinner <victor.stinner@haypocalc.com>
Sat, 1 Oct 2011 23:08:37 +0000 (01:08 +0200)
committerVictor Stinner <victor.stinner@haypocalc.com>
Sat, 1 Oct 2011 23:08:37 +0000 (01:08 +0200)
Objects/unicodeobject.c

index c0511ddc192c75fc2ac20d9a9eb410bc6030fef3..ab77b03ca68c050fb7c74d887e5f40fa602d1826 100644 (file)
@@ -8089,6 +8089,10 @@ PyUnicode_FindChar(PyObject *str, Py_UCS4 ch,
     int kind;
     if (PyUnicode_READY(str) == -1)
         return -2;
+    if (start < 0 || end < 0) {
+        PyErr_SetString(PyExc_IndexError, "string index out of range");
+        return -2;
+    }
     if (end > PyUnicode_GET_LENGTH(str))
         end = PyUnicode_GET_LENGTH(str);
     kind = PyUnicode_KIND(str);