summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorTomoyuki Sahara <[email protected]>2017-10-05 21:27:58 +0900
committerGitHub <[email protected]>2017-10-05 21:27:58 +0900
commitf8121953e7970708cf8aa1c4075cf1926b0646ee (patch)
tree644e0e7b3bbe5495697dd31c5722ad37a9a8197b /src
parent04774e5bf26b10150504635e68202a3965e2253b (diff)
parent43795cb1f1d3b15c005532a43f9e47f11acd5476 (diff)
downloadmruby-f8121953e7970708cf8aa1c4075cf1926b0646ee.tar.gz
mruby-f8121953e7970708cf8aa1c4075cf1926b0646ee.zip
Merge pull request #92 from palkan/master
Handle shared/frozen strings in IO#sysread
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);