summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/io.c3
-rw-r--r--test/io.rb1
2 files changed, 4 insertions, 0 deletions
diff --git a/src/io.c b/src/io.c
index 51a659f0e..2a24b18a4 100644
--- a/src/io.c
+++ b/src/io.c
@@ -625,6 +625,9 @@ mrb_io_sysread(mrb_state *mrb, mrb_value io)
if (maxlen < 0) {
return mrb_nil_value();
}
+ else if (maxlen == 0) {
+ return mrb_str_new(mrb, NULL, maxlen);
+ }
if (mrb_nil_p(buf)) {
buf = mrb_str_new(mrb, NULL, maxlen);
diff --git a/test/io.rb b/test/io.rb
index 955481b9f..5a95961f3 100644
--- a/test/io.rb
+++ b/test/io.rb
@@ -234,6 +234,7 @@ assert('IO.sysopen, IO#sysread') do
io.sysread(10000)
end
io.close
+ assert_equal "", io.sysread(0)
io.closed?
end