summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrii Furmanets <furmanets.andriy@gmail.com>2026-05-13 11:29:30 +0300
committerGitHub <noreply@github.com>2026-05-13 17:29:30 +0900
commitf3dd724da56ce61024781c6868577aaa79218412 (patch)
treec7445e126270276c2420b73d60c51d3141636d3c /test
parentfc5f23f8d02bd3d685292706973117dfd99c0ebe (diff)
Fix `IO::Buffer#each_byte` bounds check. (#16823)
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_io_buffer.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/ruby/test_io_buffer.rb b/test/ruby/test_io_buffer.rb
index 5662f0daf9..6213bb28d7 100644
--- a/test/ruby/test_io_buffer.rb
+++ b/test/ruby/test_io_buffer.rb
@@ -494,6 +494,14 @@ class TestIOBuffer < Test::Unit::TestCase
assert_equal string.bytes[3, 5], buffer.each_byte(3, 5).to_a
end
+ def test_each_byte_bounds_error
+ buffer = IO::Buffer.for("A")
+
+ assert_raise(ArgumentError) { buffer.each_byte(0, 2).to_a }
+ assert_raise(ArgumentError) { buffer.each_byte(1, 1).to_a }
+ assert_raise(ArgumentError) { buffer.each_byte(SIZE_MAX, 0).to_a }
+ end
+
def test_zero_length_each_byte
buffer = IO::Buffer.new(0)