diff options
| author | Vladimir Dementyev <[email protected]> | 2017-10-05 14:40:43 +0300 |
|---|---|---|
| committer | Vladimir Dementyev <[email protected]> | 2017-10-05 14:40:43 +0300 |
| commit | 4c255c77399789324e5c4d72787d87ac1fcc49dd (patch) | |
| tree | 020b966a4e2db6de97a0ccd74f2d4cce044b0efb /src | |
| parent | 04774e5bf26b10150504635e68202a3965e2253b (diff) | |
| download | mruby-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.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -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); |
