mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Improve behavioural consistency of unallocated (zero length) IO::Buffer
. (#9532)
This makes the behaviour of IO::Buffer.new(0) and IO::Buffer.new.slice(0, 0) consistent. Fixes https://bugs.ruby-lang.org/issues/19542 and https://bugs.ruby-lang.org/issues/18805.
This commit is contained in:
parent
5c823aa686
commit
c5cf4d4e12
2 changed files with 41 additions and 8 deletions
14
io_buffer.c
14
io_buffer.c
|
@ -854,11 +854,10 @@ io_buffer_get_bytes_for_writing(struct rb_io_buffer *buffer, void **base, size_t
|
|||
if (buffer->base) {
|
||||
*base = buffer->base;
|
||||
*size = buffer->size;
|
||||
|
||||
return;
|
||||
} else {
|
||||
*base = NULL;
|
||||
*size = 0;
|
||||
}
|
||||
|
||||
rb_raise(rb_eIOBufferAllocationError, "The buffer is not allocated!");
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -880,11 +879,10 @@ io_buffer_get_bytes_for_reading(struct rb_io_buffer *buffer, const void **base,
|
|||
if (buffer->base) {
|
||||
*base = buffer->base;
|
||||
*size = buffer->size;
|
||||
|
||||
return;
|
||||
} else {
|
||||
*base = NULL;
|
||||
*size = 0;
|
||||
}
|
||||
|
||||
rb_raise(rb_eIOBufferAllocationError, "The buffer is not allocated!");
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue