From 2ecfb88ee50510955acd3ae9fc94a5f109e7f109 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Thu, 28 May 2020 19:49:10 -0700 Subject: 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] --- test/test_tmpdir.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test/test_tmpdir.rb') diff --git a/test/test_tmpdir.rb b/test/test_tmpdir.rb index c599dcf516..50583b5ce1 100644 --- a/test/test_tmpdir.rb +++ b/test/test_tmpdir.rb @@ -52,6 +52,17 @@ class TestTmpdir < Test::Unit::TestCase } 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| -- cgit v1.2.3