aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tempfile.rb
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-01-09 15:46:25 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-01-09 15:46:25 +0000
commitc572ed2d25c290de7f518278dcae29d375c49d2d (patch)
tree7e70236889f2cd90b777ec8b580b8ad99662e8d0 /lib/tempfile.rb
parent896844a0cc9da1516a05b174158567d391f33288 (diff)
downloadruby-c572ed2d25c290de7f518278dcae29d375c49d2d.tar.gz
* lib/tempfile.rb (Tempfile#_close): clear @tempfile and @data[1] even
when an exception is raised at @tempfile.close. [ruby-dev:45113] * lib/tempfile.rb (Tempfile#unlink): fix a typo. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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