From 4c255c77399789324e5c4d72787d87ac1fcc49dd Mon Sep 17 00:00:00 2001 From: Vladimir Dementyev Date: Thu, 5 Oct 2017 14:40:43 +0300 Subject: Handle shared/frozen strings in IO#sysread See https://github.com/mruby/mruby/commit/7edbe428caca6814841195a3f2720745cf04353e --- src/io.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') 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); -- cgit v1.2.3