diff options
author | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2021-12-20 21:22:28 +1300 |
---|---|---|
committer | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2021-12-21 12:25:42 +1300 |
commit | 2de5dc539b299ae27ea3157ec898a6dba33b6eda (patch) | |
tree | 9cd8e5d930581d650f16004e53b0c4437a0e2981 /io_buffer.c | |
parent | c86bcd434da573982ab52522a301ba5499dc13ed (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.c | 4 |
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); |