summaryrefslogtreecommitdiff
path: root/test/ruby/test_string.rb
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2023-07-22 13:39:44 +0900
committernagachika <nagachika@ruby-lang.org>2023-07-22 13:39:44 +0900
commit65d294ad019c8ac5bba12e2c9098360bacafc9e3 (patch)
tree519befb52f5470baade380c01f6d5a1e0a82f788 /test/ruby/test_string.rb
parent35cf3a5f8d01aad07762eb824c3107bee9ae7fdd (diff)
merge revision(s) bc3ac1872e4523334e3ed04c2bb70a55c4c43f98: [Backport #19748]
[Bug #19748] Fix out-of-bound access in `String#byteindex` --- string.c | 17 +++++++---------- test/ruby/test_string.rb | 3 +++ 2 files changed, 10 insertions(+), 10 deletions(-)
Diffstat (limited to 'test/ruby/test_string.rb')
-rw-r--r--test/ruby/test_string.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index 615ede2234..7c685407d6 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -3376,6 +3376,9 @@ CODE
assert_equal(6, S("にんにちは").byteindex(S("に"), 6))
assert_equal(6, S("にんにちは").byteindex(/に./, 6))
assert_raise(IndexError) { S("にんにちは").byteindex(?に, 7) }
+
+ s = S("foobarbarbaz")
+ assert !1000.times.any? {s.byteindex("", 100_000_000)}
end
def test_byterindex