Bug #5237 ยป 0001-avoid-infinite-loop-of-IO.copy_stream.patch
io.c | ||
---|---|---|
l = buflen < rest ? buflen : (long)rest;
|
||
}
|
||
if (stp->src_fd == -1) {
|
||
rb_funcall(stp->src, read_method, 2, INT2FIX(l), buf);
|
||
VALUE rc = rb_funcall(stp->src, read_method, 2, INT2FIX(l), buf);
|
||
if (read_method == id_read && NIL_P(rc))
|
||
break;
|
||
}
|
||
else {
|
||
ssize_t ss;
|
test/ruby/test_io.rb | ||
---|---|---|
}
|
||
end
|
||
class Bug5237
|
||
attr_reader :count
|
||
def initialize
|
||
@count = 0
|
||
end
|
||
def read(bytes, buffer)
|
||
@count += 1
|
||
buffer.replace "this is a test"
|
||
nil
|
||
end
|
||
end
|
||
def test_copy_stream_broken_src_read_eof
|
||
src = Bug5237.new
|
||
dst = StringIO.new
|
||
assert_equal 0, src.count
|
||
th = Thread.new { IO.copy_stream(src, dst) }
|
||
flunk("timeout") unless th.join(10)
|
||
assert_equal 1, src.count
|
||
end
|
||
def test_copy_stream_dst_rbuf
|
||
mkcdtmpdir {
|
||
pipe(proc do |w|
|