IO#sysread should raise error when invalid pos

This commit is contained in:
ksss
2017-05-21 22:55:28 +09:00
parent 86edc9ab85
commit 0bbd60b523
2 changed files with 2 additions and 1 deletions
+1 -1
View File
@@ -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);
+1
View File
@@ -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