io.c: ARGF fd leak
* io.c (argf_next_argv): fix leak of fd after breaking in #each method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57203 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
bc855ef139
commit
2fbc63b8a8
1
io.c
1
io.c
@ -8023,6 +8023,7 @@ argf_next_argv(VALUE argf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ARGF.next_p == 1) {
|
if (ARGF.next_p == 1) {
|
||||||
|
if (ARGF.init_p == 1) argf_close(argf);
|
||||||
retry:
|
retry:
|
||||||
if (RARRAY_LEN(ARGF.argv) > 0) {
|
if (RARRAY_LEN(ARGF.argv) > 0) {
|
||||||
VALUE filename = rb_ary_shift(ARGF.argv);
|
VALUE filename = rb_ary_shift(ARGF.argv);
|
||||||
|
@ -137,7 +137,7 @@ class TestArgf < Test::Unit::TestCase
|
|||||||
INPUT
|
INPUT
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_new_lineno
|
def test_new_lineno_each
|
||||||
f = ARGF.class.new(@t1.path, @t2.path, @t3.path)
|
f = ARGF.class.new(@t1.path, @t2.path, @t3.path)
|
||||||
result = []
|
result = []
|
||||||
f.each {|line| result << [f.lineno, line]; break if result.size == 3}
|
f.each {|line| result << [f.lineno, line]; break if result.size == 3}
|
||||||
@ -146,10 +146,16 @@ class TestArgf < Test::Unit::TestCase
|
|||||||
|
|
||||||
f.rewind
|
f.rewind
|
||||||
assert_equal(2, f.lineno)
|
assert_equal(2, f.lineno)
|
||||||
|
ensure
|
||||||
|
f.close
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_new_lineno_each_char
|
||||||
f = ARGF.class.new(@t1.path, @t2.path, @t3.path)
|
f = ARGF.class.new(@t1.path, @t2.path, @t3.path)
|
||||||
f.each_char.to_a
|
f.each_char.to_a
|
||||||
assert_equal(0, f.lineno)
|
assert_equal(0, f.lineno)
|
||||||
|
ensure
|
||||||
|
f.close
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_inplace
|
def test_inplace
|
||||||
|
Loading…
x
Reference in New Issue
Block a user