зеркало из https://github.com/github/ruby.git
Родитель
11c32e33eb
Коммит
19346c2336
|
@ -1156,6 +1156,9 @@ VALUE rb_io_buffer_free_locked(VALUE self)
|
|||
static inline void
|
||||
io_buffer_validate_range(struct rb_io_buffer *buffer, size_t offset, size_t length)
|
||||
{
|
||||
if (offset > buffer->size) {
|
||||
rb_raise(rb_eArgError, "Specified offset exceeds buffer size!");
|
||||
}
|
||||
if (offset + length > buffer->size) {
|
||||
rb_raise(rb_eArgError, "Specified offset+length exceeds buffer size!");
|
||||
}
|
||||
|
|
|
@ -251,6 +251,14 @@ class TestIOBuffer < Test::Unit::TestCase
|
|||
|
||||
chunk = buffer.get_string(0, message.bytesize, Encoding::BINARY)
|
||||
assert_equal Encoding::BINARY, chunk.encoding
|
||||
|
||||
assert_raise_with_message(ArgumentError, /exceeds buffer size/) do
|
||||
buffer.get_string(0, 129)
|
||||
end
|
||||
|
||||
assert_raise_with_message(ArgumentError, /exceeds buffer size/) do
|
||||
buffer.get_string(129)
|
||||
end
|
||||
end
|
||||
|
||||
# We check that values are correctly round tripped.
|
||||
|
|
Загрузка…
Ссылка в новой задаче