[ruby/stringio] Fix SEGV at read/pread on null StringIO

113dd5a55e
This commit is contained in:
Nobuyoshi Nakada 2025-08-09 19:44:26 +09:00 committed by git
parent 23c0113932
commit 31f2d8990d
2 changed files with 29 additions and 9 deletions

View file

@ -70,6 +70,16 @@ class TestStringIO < Test::Unit::TestCase
assert_nil io.getc
end
def test_pread_null
io = StringIO.new(nil)
assert_raise(EOFError) { io.pread(1, 0) }
end
def test_read_null
io = StringIO.new(nil)
assert_equal "", io.read(0)
end
def test_seek_null
io = StringIO.new(nil)
assert_equal(0, io.seek(0, IO::SEEK_SET))