Bug #6764 ยป fix_read_buf.patch
io.c | ||
---|---|---|
rb_sys_fail_path(fptr->pathv);
|
||
}
|
||
}
|
||
rb_str_set_len(str, n);
|
||
if (RSTRING_LEN(str) != n) {
|
||
rb_str_modify(str);
|
||
rb_str_set_len(str, n);
|
||
}
|
||
if (n == 0)
|
||
return Qnil;
|
||
... | ... | |
previous_mode = set_binary_mode_with_seek_cur(fptr);
|
||
#endif
|
||
n = io_fread(str, 0, len, fptr);
|
||
rb_str_set_len(str, n);
|
||
if (RSTRING_LEN(str) != n) {
|
||
rb_str_modify(str);
|
||
rb_str_set_len(str, n);
|
||
}
|
||
#if defined(RUBY_TEST_CRLF_ENVIRONMENT) || defined(_WIN32)
|
||
if (previous_mode == O_TEXT) {
|
||
setmode(fptr->fd, O_TEXT);
|
||
... | ... | |
if (n == -1) {
|
||
rb_sys_fail_path(fptr->pathv);
|
||
}
|
||
rb_str_set_len(str, n);
|
||
if (RSTRING_LEN(str) != n) {
|
||
rb_str_modify(str);
|
||
rb_str_set_len(str, n);
|
||
}
|
||
if (n == 0 && ilen > 0) {
|
||
rb_eof_error();
|
||
}
|
test/ruby/test_io.rb | ||
---|---|---|
assert_raise(Errno::ESPIPE, Errno::EINVAL) { w.advise(:willneed) }
|
||
end
|
||
end
|
||
def test_read_buffer_not_raise_shared_string_error
|
||
bug6764 = '[ruby-core:46586]'
|
||
size = 28
|
||
t = Tempfile.new("test_io")
|
||
t.write("a" * size)
|
||
t.close
|
||
w = Tempfile.new("test_io")
|
||
assert_nothing_raised(RuntimeError, bug6764) do
|
||
File.open(t.path, "r") do |r|
|
||
buf = ''
|
||
while r.read(size, buf)
|
||
w << buf
|
||
end
|
||
end
|
||
end
|
||
ensure
|
||
t.close!
|
||
w.close!
|
||
end
|
||
def test_sysread_buffer_not_raise_shared_string_error
|
||
bug6764 = '[ruby-core:46586]'
|
||
size = 28
|
||
t = Tempfile.new("test_io")
|
||
t.write("a" * size)
|
||
t.close
|
||
w = Tempfile.new("test_io")
|
||
assert_nothing_raised(RuntimeError, bug6764) do
|
||
File.open(t.path, "r") do |r|
|
||
buf = ''
|
||
begin
|
||
while r.sysread(size, buf)
|
||
w << buf
|
||
end
|
||
rescue EOFError
|
||
end
|
||
end
|
||
end
|
||
ensure
|
||
t.close!
|
||
w.close!
|
||
end
|
||
def test_readpartial_buffer_not_raise_shared_string_error
|
||
bug6764 = '[ruby-core:46586]'
|
||
size = 28
|
||
t = Tempfile.new("test_io")
|
||
t.write("a" * size)
|
||
t.close
|
||
w = Tempfile.new("test_io")
|
||
assert_nothing_raised(RuntimeError, bug6764) do
|
||
File.open(t.path, "r") do |r|
|
||
buf = ''
|
||
begin
|
||
while r.readpartial(size, buf)
|
||
w << buf
|
||
end
|
||
rescue EOFError
|
||
end
|
||
end
|
||
end
|
||
ensure
|
||
t.close!
|
||
w.close!
|
||
end
|
||
end
|
||