diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tempfile.rb | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/tempfile.rb b/lib/tempfile.rb index 22401b030c..8a517d6746 100644 --- a/lib/tempfile.rb +++ b/lib/tempfile.rb @@ -162,9 +162,12 @@ class Tempfile < DelegateClass(File) end def _close # :nodoc: - @tmpfile.close if @tmpfile - @tmpfile = nil - @data[1] = nil if @data + begin + @tmpfile.close if @tmpfile + ensure + @tmpfile = nil + @data[1] = nil if @data + end end protected :_close @@ -231,7 +234,7 @@ class Tempfile < DelegateClass(File) File.unlink(@tmpname) end # remove tmpname from remover - @data[0] = @data[2] = nil + @data[0] = @data[1] = nil @tmpname = nil rescue Errno::EACCES # may not be able to unlink on Windows; just ignore |