From 66b54b1a4ae9f3d38c47e23ecec6a40c07a80c21 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 16 May 2017 05:47:53 +0000 Subject: fix tempfile leaks on Windows * lib/rubygems/ext/ext_conf_builder.rb (build): needs to close before unlink on Windows. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rubygems/ext/ext_conf_builder.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lib/rubygems/ext/ext_conf_builder.rb') diff --git a/lib/rubygems/ext/ext_conf_builder.rb b/lib/rubygems/ext/ext_conf_builder.rb index b6dde01950..965b728278 100644 --- a/lib/rubygems/ext/ext_conf_builder.rb +++ b/lib/rubygems/ext/ext_conf_builder.rb @@ -27,9 +27,7 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder # TODO: Make this unconditional when rubygems no longer supports Ruby 1.9.x. tmp_dest = get_relative_path(tmp_dest) unless Gem.win_platform? && RUBY_VERSION <= '2.0' - t = nil Tempfile.open %w"siteconf .rb", "." do |siteconf| - t = siteconf siteconf.puts "require 'rbconfig'" siteconf.puts "dest_path = #{tmp_dest.dump}" %w[sitearchdir sitelibdir].each do |dir| @@ -37,7 +35,7 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder siteconf.puts "RbConfig::CONFIG['#{dir}'] = dest_path" end - siteconf.flush + siteconf.close destdir = ENV["DESTDIR"] @@ -78,9 +76,9 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder end ensure ENV["DESTDIR"] = destdir + siteconf.close! end end - t.unlink if t and t.path results ensure -- cgit v1.2.3