summaryrefslogtreecommitdiff
path: root/io_buffer.c
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2021-12-20 21:22:28 +1300
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2021-12-21 12:25:42 +1300
commit2de5dc539b299ae27ea3157ec898a6dba33b6eda (patch)
tree9cd8e5d930581d650f16004e53b0c4437a0e2981 /io_buffer.c
parentc86bcd434da573982ab52522a301ba5499dc13ed (diff)
Fix handling of clear with offset and without length.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5303
Diffstat (limited to 'io_buffer.c')
-rw-r--r--io_buffer.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/io_buffer.c b/io_buffer.c
index d87575bfdd..2b775a8234 100644
--- a/io_buffer.c
+++ b/io_buffer.c
@@ -1180,9 +1180,11 @@ io_buffer_clear(int argc, VALUE *argv, VALUE self)
offset = NUM2SIZET(argv[1]);
}
- size_t length = data->size;
+ size_t length;
if (argc >= 3) {
length = NUM2SIZET(argv[2]);
+ } else {
+ length = data->size - offset;
}
rb_io_buffer_clear(self, value, offset, length);