Skip to content

Commit 7d49e2b

Browse files
committed
merge revision(s) r45979: [Backport ruby#9847]
* io.c (io_setstrbuf): always check if the buffer is modifiable. [ruby-core:62643] [Bug ruby#9847] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 4c5d8be commit 7d49e2b

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

ChangeLog

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Mon Jun 30 02:28:10 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
2+
3+
* io.c (io_setstrbuf): always check if the buffer is modifiable.
4+
[ruby-core:62643] [Bug #9847]
5+
16
Mon Jun 30 02:25:00 2014 Tanaka Akira <akr@fsij.org>
27

38
* ext/openssl/lib/openssl/ssl.rb (OpenSSL::SSL::SSLServer#accept):

io.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2290,8 +2290,8 @@ io_setstrbuf(VALUE *str, long len)
22902290
VALUE s = StringValue(*str);
22912291
long clen = RSTRING_LEN(s);
22922292
if (clen >= len) {
2293+
rb_str_modify(s);
22932294
if (clen != len) {
2294-
rb_str_modify(s);
22952295
rb_str_set_len(s, len);
22962296
}
22972297
return;

test/ruby/test_io.rb

+5-6
Original file line numberDiff line numberDiff line change
@@ -2790,25 +2790,24 @@ def test_advise_pipe
27902790

27912791
def assert_buffer_not_raise_shared_string_error
27922792
bug6764 = '[ruby-core:46586]'
2793+
bug9847 = '[ruby-core:62643] [Bug #9847]'
27932794
size = 28
27942795
data = [*"a".."z", *"A".."Z"].shuffle.join("")
27952796
t = Tempfile.new("test_io")
27962797
t.write(data)
27972798
t.close
2798-
w = Tempfile.new("test_io")
2799+
w = []
27992800
assert_nothing_raised(RuntimeError, bug6764) do
2801+
buf = ''
28002802
File.open(t.path, "r") do |r|
2801-
buf = ''
28022803
while yield(r, size, buf)
2803-
w << buf
2804+
w << buf.dup
28042805
end
28052806
end
28062807
end
2807-
w.close
2808-
assert_equal(data, w.open.read, bug6764)
2808+
assert_equal(data, w.join(""), bug9847)
28092809
ensure
28102810
t.close!
2811-
w.close!
28122811
end
28132812

28142813
def test_read_buffer_not_raise_shared_string_error

version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define RUBY_VERSION "2.1.2"
22
#define RUBY_RELEASE_DATE "2014-06-30"
3-
#define RUBY_PATCHLEVEL 151
3+
#define RUBY_PATCHLEVEL 152
44

55
#define RUBY_RELEASE_YEAR 2014
66
#define RUBY_RELEASE_MONTH 6

0 commit comments

Comments
 (0)