From 9865ee2c46b7cc9244c3d78b786ee14a7a302e53 Mon Sep 17 00:00:00 2001 From: tarui Date: Tue, 7 Dec 2010 13:38:36 +0000 Subject: * io.c (io_read): duplicate string if shared. [ruby-dev:42719] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30122 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- io.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'io.c') diff --git a/io.c b/io.c index 26af3ce6ef..d5d1220294 100644 --- a/io.c +++ b/io.c @@ -2212,7 +2212,10 @@ io_read(int argc, VALUE *argv, VALUE io) rb_scan_args(argc, argv, "02", &length, &str); if (NIL_P(length)) { - if (!NIL_P(str)) StringValue(str); + if (!NIL_P(str)){ + StringValue(str); + rb_str_modify(str); + } GetOpenFile(io, fptr); rb_io_check_char_readable(fptr); return read_all(fptr, remain_size(fptr), str); -- cgit v1.2.3