diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | io.c | 2 | ||||
-rw-r--r-- | test/ruby/test_io.rb | 11 | ||||
-rw-r--r-- | version.h | 2 |
4 files changed, 12 insertions, 8 deletions
@@ -1,3 +1,8 @@ +Fri Jun 27 17:19:22 2014 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * io.c (io_setstrbuf): always check if the buffer is modifiable. + [ruby-core:62643] [Bug #9847] + Fri Jun 27 17:15:36 2014 Tanaka Akira <akr@fsij.org> * ext/openssl/lib/openssl/ssl.rb (OpenSSL::SSL::SSLServer#accept): @@ -2253,8 +2253,8 @@ io_setstrbuf(VALUE *str, long len) VALUE s = StringValue(*str); long clen = RSTRING_LEN(s); if (clen >= len) { + rb_str_modify(s); if (clen != len) { - rb_str_modify(s); rb_str_set_len(s, len); } return; diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index e7384390be..566564af03 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -2595,25 +2595,24 @@ End def assert_buffer_not_raise_shared_string_error bug6764 = '[ruby-core:46586]' + bug9847 = '[ruby-core:62643] [Bug #9847]' size = 28 data = [*"a".."z", *"A".."Z"].shuffle.join("") t = Tempfile.new("test_io") t.write(data) t.close - w = Tempfile.new("test_io") + w = [] assert_nothing_raised(RuntimeError, bug6764) do + buf = '' File.open(t.path, "r") do |r| - buf = '' while yield(r, size, buf) - w << buf + w << buf.dup end end end - w.close - assert_equal(data, w.open.read, bug6764) + assert_equal(data, w.join(""), bug9847) ensure t.close! - w.close! end def test_read_buffer_not_raise_shared_string_error @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.0.0" #define RUBY_RELEASE_DATE "2014-06-27" -#define RUBY_PATCHLEVEL 504 +#define RUBY_PATCHLEVEL 505 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 |