summaryrefslogtreecommitdiff
path: root/test/pathname
diff options
context:
space:
mode:
authorKenichi Kamiya <kachick1@gmail.com>2021-03-27 14:45:10 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-03-28 14:04:10 +0900
commit9af57eeed61ad53c0a2a92a93a6a6e40704cd6ae (patch)
tree4fb3780543ce4d0c4d6a10c754caecd275d132f3 /test/pathname
parent447e095413557330760558c2b0e1d82c3aa685f1 (diff)
[ruby/pathname] Fix segfault of Pathname#split
Fix segmentation fault of Pathname#split when File.split returns non array value [Bug #17755] https://github.com/ruby/pathname/commit/e29b49e3b1 https://github.com/ruby/pathname/commit/1db7479a74
Diffstat (limited to 'test/pathname')
-rw-r--r--test/pathname/test_pathname.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb
index 46a04ee2b6..8a0f3cbb66 100644
--- a/test/pathname/test_pathname.rb
+++ b/test/pathname/test_pathname.rb
@@ -1067,6 +1067,21 @@ class TestPathname < Test::Unit::TestCase
def test_split
assert_equal([Pathname("dirname"), Pathname("basename")], Pathname("dirname/basename").split)
+
+ assert_separately([], <<-'end;')
+ require 'pathname'
+
+ mod = Module.new do
+ def split(_arg)
+ end
+ end
+
+ File.singleton_class.prepend(mod)
+
+ assert_raise(TypeError) do
+ Pathname('/').split
+ end
+ end;
end
def test_blockdev?