summaryrefslogtreecommitdiff
path: root/lib/tempfile.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-19 09:36:34 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-19 09:36:34 +0000
commita6df192ded23960bc45b402e70168d4c67e96c6b (patch)
treee643714ef8215651eec7f8d4b2064976b742f2af /lib/tempfile.rb
parent940f32eb5d670388abad58246a2618ef3c7ccfba (diff)
downloadruby-a6df192ded23960bc45b402e70168d4c67e96c6b.tar.gz
tempfile.rb: do not call File.identical? on closed stream
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/tempfile.rb')
-rw-r--r--lib/tempfile.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/tempfile.rb b/lib/tempfile.rb
index b6270b827a..85b7720a48 100644
--- a/lib/tempfile.rb
+++ b/lib/tempfile.rb
@@ -334,10 +334,12 @@ def Tempfile.create(basename="", tmpdir=nil, mode: 0, **options)
begin
yield tmpfile
ensure
- if File.identical?(tmpfile, tmpfile.path)
- unlinked = File.unlink tmpfile.path rescue nil
+ unless tmpfile.closed?
+ if File.identical?(tmpfile, tmpfile.path)
+ unlinked = File.unlink tmpfile.path rescue nil
+ end
+ tmpfile.close
end
- tmpfile.close
unless unlinked
begin
File.unlink tmpfile.path