diff options
author | Jean byroot Boussier <[email protected]> | 2023-10-05 09:43:59 +0200 |
---|---|---|
committer | git <[email protected]> | 2023-10-05 07:44:08 +0000 |
commit | f087f2c74c99ec5fed04896d3dc91ff76c2b16b8 () | |
tree | a66f6c9ab91ac35c6e36df5e474b4a9750daf1e3 /ext/stringio | |
parent | 9d58f9382893a71d8badad605879c0120915fbee (diff) |
[ruby/stringio] StringIO#pread: handle 0 length like IO#pread
(https://.com/ruby/stringio/pull/67) Fix: https://.com/ruby/stringio/issues/66 If length is 0, IO#pread don't even try to read the IO, it simply return the buffer untouched if there is one or a new empty buffer otherwise. It also doesn't validate the offset when length is 0. cc @jdelStrother @kou https://.com/ruby/stringio/commit/37e9279337 Co-authored-by: Jean Boussier <[email protected]>
-rw-r--r-- | ext/stringio/stringio.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -1602,6 +1602,13 @@ strio_pread(int argc, VALUE *argv, VALUE self) rb_raise(rb_eArgError, "negative string size (or size too big): %" PRIsVALUE, rb_len); } if (offset < 0) { rb_syserr_fail_str(EINVAL, rb_sprintf("pread: Invalid offset argument: %" PRIsVALUE, rb_offset)); } |