summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorVladimir Dementyev <[email protected]>2017-10-05 14:40:43 +0300
committerVladimir Dementyev <[email protected]>2017-10-05 14:40:43 +0300
commit4c255c77399789324e5c4d72787d87ac1fcc49dd (patch)
tree020b966a4e2db6de97a0ccd74f2d4cce044b0efb /src
parent04774e5bf26b10150504635e68202a3965e2253b (diff)
downloadmruby-4c255c77399789324e5c4d72787d87ac1fcc49dd.tar.gz
mruby-4c255c77399789324e5c4d72787d87ac1fcc49dd.zip
Handle shared/frozen strings in IO#sysread
See https://github.com/mruby/mruby/commit/7edbe428caca6814841195a3f2720745cf04353e
Diffstat (limited to 'src')
-rw-r--r--src/io.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/io.c b/src/io.c
index 992801a62..6f52daf4a 100644
--- a/src/io.c
+++ b/src/io.c
@@ -630,8 +630,13 @@ mrb_io_sysread(mrb_state *mrb, mrb_value io)
if (mrb_nil_p(buf)) {
buf = mrb_str_new(mrb, NULL, maxlen);
}
+
+ mrb_str_modify(mrb, RSTRING(buf));
+
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);