From bc3ac1872e4523334e3ed04c2bb70a55c4c43f98 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 28 Jun 2023 14:44:01 +0900 Subject: [Bug #19748] Fix out-of-bound access in `String#byteindex` --- test/ruby/test_string.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index 215fccfb64..06df67de38 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -3397,6 +3397,9 @@ CODE assert_byteindex(6, S("にんにちは"), S("に"), 6) assert_byteindex(6, S("にんにちは"), /に./, 6) assert_raise(IndexError) { S("にんにちは").byteindex(?に, 7) } + + s = S("foobarbarbaz") + assert !1000.times.any? {s.byteindex("", 100_000_000)} end def test_byterindex -- cgit v1.2.3