[前][次][番号順一覧][スレッド一覧]

ruby-changes:62365

From: nagachika <ko1@a...>
Date: Thu, 23 Jul 2020 11:16:43 +0900 (JST)
Subject: [ruby-changes:62365] 13d2ab0d88 (ruby_2_7): merge revision(s) 2ecfb88ee50510955acd3ae9fc94a5f109e7f109: [Backport #16918]

https://git.ruby-lang.org/ruby.git/commit/?id=13d2ab0d88

From 13d2ab0d88bbf72ed310efaec6edc46dd96fdb4d Mon Sep 17 00:00:00 2001
From: nagachika <nagachika@r...>
Date: Thu, 23 Jul 2020 11:16:31 +0900
Subject: merge revision(s) 2ecfb88ee50510955acd3ae9fc94a5f109e7f109: [Backport
 #16918]

	Correctly remove temporary directory if path yielded is mutated

	Another approach would be to freeze the string, but that could
	cause backwards compatibility issues.

	Fixes [Bug #16918]

diff --git a/lib/tmpdir.rb b/lib/tmpdir.rb
index ea1d380..1bbf7ea 100644
--- a/lib/tmpdir.rb
+++ b/lib/tmpdir.rb
@@ -86,7 +86,7 @@ class Dir https://github.com/ruby/ruby/blob/trunk/lib/tmpdir.rb#L86
     }
     if block_given?
       begin
-        yield path
+        yield path.dup
       ensure
         unless base
           stat = File.stat(File.dirname(path))
diff --git a/test/test_tmpdir.rb b/test/test_tmpdir.rb
index c599dcf..50583b5 100644
--- a/test/test_tmpdir.rb
+++ b/test/test_tmpdir.rb
@@ -52,6 +52,17 @@ class TestTmpdir < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/test_tmpdir.rb#L52
     }
   end
 
+  def test_mktmpdir_mutate
+    bug16918 = '[ruby-core:98563]'
+    assert_nothing_raised(bug16918) do
+      assert_mktmpdir_traversal do |traversal_path|
+        Dir.mktmpdir(traversal_path + 'foo') do |actual|
+          actual << "foo"
+        end
+      end
+    end
+  end
+
   def test_mktmpdir_traversal
     assert_mktmpdir_traversal do |traversal_path|
       Dir.mktmpdir(traversal_path + 'foo') do |actual|
diff --git a/version.h b/version.h
index bbb9fc4..7ff1cd9 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L2
 # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
 #define RUBY_VERSION_TEENY 1
 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 98
+#define RUBY_PATCHLEVEL 99
 
 #define RUBY_RELEASE_YEAR 2020
 #define RUBY_RELEASE_MONTH 7
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]