summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-11 13:02:37 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-11 13:02:37 +0000
commit2f1cc54d5fd9078c90ad240fce4f132feb1eaffe (patch)
treeaf9d87c2796432c06bc0aa71162f65907bd6df8f
parent1c13c7fa8864648c018966354b469fe5ff8deaa4 (diff)
merge revision(s) 57203:
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/branches/ruby_2_4@57839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--io.c1
-rw-r--r--test/ruby/test_argf.rb8
-rw-r--r--version.h2
3 files changed, 9 insertions, 2 deletions
diff --git a/io.c b/io.c
index 03388961f6..873b477ab5 100644
--- a/io.c
+++ b/io.c
@@ -8023,6 +8023,7 @@ argf_next_argv(VALUE argf)
}
if (ARGF.next_p == 1) {
+ if (ARGF.init_p == 1) argf_close(argf);
retry:
if (RARRAY_LEN(ARGF.argv) > 0) {
VALUE filename = rb_ary_shift(ARGF.argv);
diff --git a/test/ruby/test_argf.rb b/test/ruby/test_argf.rb
index fdd31c630a..d6aa8f7295 100644
--- a/test/ruby/test_argf.rb
+++ b/test/ruby/test_argf.rb
@@ -137,7 +137,7 @@ class TestArgf < Test::Unit::TestCase
INPUT
end
- def test_new_lineno
+ def test_new_lineno_each
f = ARGF.class.new(@t1.path, @t2.path, @t3.path)
result = []
f.each {|line| result << [f.lineno, line]; break if result.size == 3}
@@ -146,10 +146,16 @@ class TestArgf < Test::Unit::TestCase
f.rewind
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.each_char.to_a
assert_equal(0, f.lineno)
+ ensure
+ f.close
end
def test_inplace
diff --git a/version.h b/version.h
index b8bec78d34..390006b1ae 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.4.0"
#define RUBY_RELEASE_DATE "2017-03-11"
-#define RUBY_PATCHLEVEL 7
+#define RUBY_PATCHLEVEL 8
#define RUBY_RELEASE_YEAR 2017
#define RUBY_RELEASE_MONTH 3