mirror of
https://github.com/ruby/ruby.git
synced 2025-09-17 17:43:59 +02:00
Raise ArgumentError if IO.read is provided negative offset
Fixes [Bug #19380]
This commit is contained in:
parent
836e9a192b
commit
6c60006de5
Notes:
git
2023-03-24 19:29:23 +00:00
3 changed files with 19 additions and 3 deletions
4
io.c
4
io.c
|
@ -12125,9 +12125,13 @@ static VALUE
|
|||
rb_io_s_read(int argc, VALUE *argv, VALUE io)
|
||||
{
|
||||
VALUE opt, offset;
|
||||
long off;
|
||||
struct foreach_arg arg;
|
||||
|
||||
argc = rb_scan_args(argc, argv, "13:", NULL, NULL, &offset, NULL, &opt);
|
||||
if (!NIL_P(offset) && (off = NUM2LONG(offset)) < 0) {
|
||||
rb_raise(rb_eArgError, "negative offset %ld given", off);
|
||||
}
|
||||
open_key_args(io, argc, argv, opt, &arg);
|
||||
if (NIL_P(arg.io)) return Qnil;
|
||||
if (!NIL_P(offset)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue