mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
IO#sysread should raise error when invalid pos
This commit is contained in:
@@ -623,7 +623,7 @@ mrb_io_sysread(mrb_state *mrb, mrb_value io)
|
||||
|
||||
mrb_get_args(mrb, "i|S", &maxlen, &buf);
|
||||
if (maxlen < 0) {
|
||||
return mrb_nil_value();
|
||||
mrb_raise(mrb, E_ARGUMENT_ERROR, "negative expanding string size");
|
||||
}
|
||||
else if (maxlen == 0) {
|
||||
return mrb_str_new(mrb, NULL, maxlen);
|
||||
|
||||
@@ -236,6 +236,7 @@ assert('IO.sysopen, IO#sysread') do
|
||||
io.close
|
||||
assert_equal "", io.sysread(0)
|
||||
assert_raise(IOError) { io.sysread(1) }
|
||||
assert_raise(ArgumentError) { io.sysread(-1) }
|
||||
io.closed?
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user