Handle shared/frozen strings in IO#sysread
See
MODIFY
src/io.c
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);

MODIFY
test/io.rb
test/io.rb
@@ -250,6 +250,11 @@ assert('IO.sysopen, IO#sysread') do
io.sysread(10000)
io.sysread(10000)
end
+
+ assert_raise RuntimeError do
+ io.sysread(5, "abcde".freeze)
+ end
+
io.close
assert_equal "", io.sysread(0)
assert_raise(IOError) { io.sysread(1) }

Handle shared/frozen strings in IO#sysread

See https://github.com/mruby/mruby/commit/7edbe428caca6814841195a3f2720745cf04353e