Index: Objects/stringlib/find.h =================================================================== --- Objects/stringlib/find.h (révision 76700) +++ Objects/stringlib/find.h (copie de travail) @@ -63,6 +63,8 @@ end += str_len; if (end < 0) end = 0; + if (end < start) + return -1; return stringlib_find( str + start, end - start, @@ -85,6 +87,8 @@ end += str_len; if (end < 0) end = 0; + if (end < start) + return -1; return stringlib_rfind(str + start, end - start, sub, sub_len, start); } Index: Lib/test/string_tests.py =================================================================== --- Lib/test/string_tests.py (révision 76700) +++ Lib/test/string_tests.py (copie de travail) @@ -185,6 +185,9 @@ self.checkequal(-1, '', 'find', 'xx', 1, 1) self.checkequal(-1, '', 'find', 'xx', sys.maxint, 0) + # issue 7458 + self.checkequal(-1, 'ab', 'find', 'xxx', 6287518193, 0) + # For a variety of combinations, # verify that str.find() matches __contains__ # and that the found substring is really at that location @@ -230,6 +233,9 @@ self.checkraises(TypeError, 'hello', 'rfind') self.checkraises(TypeError, 'hello', 'rfind', 42) + # issue 7458 + self.checkequal(-1, 'ab', 'rfind', 'xxx', 6287518193, 0) + def test_index(self): self.checkequal(0, 'abcdefghiabc', 'index', '') self.checkequal(3, 'abcdefghiabc', 'index', 'def')