From 7eed0ca619fc7602737bb81d42a63dc60751367b Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 15 Feb 2012 08:45:15 +0000 Subject: [PATCH] * io.c (io_strsetbuf): call rb_str_modify to make str independent before calling rb_str_set_len for r34580. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ io.c | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 64071007c5..c649166b95 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Feb 15 17:41:31 2012 NARUSE, Yui + + * io.c (io_strsetbuf): call rb_str_modify to make str independent + before calling rb_str_set_len for r34580. + Wed Feb 15 12:30:10 2012 Eric Hodel * ext/zlib/zlib.c (Init_zlib): Added Zlib::TEXT and note that diff --git a/io.c b/io.c index 074d2c50f7..f404b539a4 100644 --- a/io.c +++ b/io.c @@ -2084,7 +2084,10 @@ io_setstrbuf(VALUE *str, long len) VALUE s = StringValue(*str); long clen = RSTRING_LEN(s); if (clen >= len) { - if (clen != len) rb_str_set_len(s, len); + if (clen != len) { + rb_str_modify(s); + rb_str_set_len(s, len); + } return; } len -= clen;