1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2017-05-19 09:36:34 +00:00
parent 940f32eb5d
commit a6df192ded

View file

@ -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