Validate string type when constructing IO::Buffer for string mapping.
This commit is contained in:
parent
a19a657514
commit
5190926e40
Notes:
git
2021-11-17 06:40:14 +09:00
@ -259,6 +259,8 @@ rb_io_buffer_type_allocate(VALUE self)
|
||||
VALUE
|
||||
rb_io_buffer_type_for(VALUE klass, VALUE string)
|
||||
{
|
||||
StringValue(string);
|
||||
|
||||
VALUE instance = rb_io_buffer_type_allocate(klass);
|
||||
|
||||
struct rb_io_buffer *data = NULL;
|
||||
|
@ -81,6 +81,14 @@ class TestIOBuffer < Test::Unit::TestCase
|
||||
assert_equal "Hello World", string
|
||||
end
|
||||
|
||||
def test_non_string
|
||||
not_string = Object.new
|
||||
|
||||
assert_raise TypeError do
|
||||
IO::Buffer.for(not_string)
|
||||
end
|
||||
end
|
||||
|
||||
def test_resize
|
||||
buffer = IO::Buffer.new(1024, IO::Buffer::MAPPED)
|
||||
buffer.resize(2048, 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user