aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tempfile.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tempfile.rb')
-rw-r--r--lib/tempfile.rb11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/tempfile.rb b/lib/tempfile.rb
index 3321116792..5e860db095 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