Project

General

Profile

Bug #5237 ยป 0001-avoid-infinite-loop-of-IO.copy_stream.patch

normalperson (Eric Wong), 08/27/2011 07:54 PM

View differences:

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|
    (1-1/1)