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 From 43795cb1f1d3b15c005532a43f9e47f11acd5476 Mon Sep 17 00:00:00 2001 From: Vladimir Dementyev Date: Thu, 5 Oct 2017 15:22:57 +0300 Subject: Remove useless mrb_str_modify --- src/io.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/io.c b/src/io.c index 6f52daf4a..8792bb2aa 100644 --- a/src/io.c +++ b/src/io.c @@ -631,8 +631,6 @@ mrb_io_sysread(mrb_state *mrb, mrb_value io) 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 { -- cgit v1.2.3