summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/io.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/io.c b/src/io.c
index 992801a62..8792bb2aa 100644
--- a/src/io.c
+++ b/src/io.c
@@ -630,8 +630,11 @@ mrb_io_sysread(mrb_state *mrb, mrb_value io)
if (mrb_nil_p(buf)) {
buf = mrb_str_new(mrb, NULL, maxlen);
}
+
if (RSTRING_LEN(buf) != maxlen) {
buf = mrb_str_resize(mrb, buf, maxlen);
+ } else {
+ mrb_str_modify(mrb, RSTRING(buf));
}
fptr = (struct mrb_io *)io_get_open_fptr(mrb, io);