зеркало из https://github.com/github/ruby.git
[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
This commit is contained in:
Родитель
447e095413
Коммит
9af57eeed6
|
@ -834,7 +834,7 @@ path_split(VALUE self)
|
|||
VALUE str = get_strpath(self);
|
||||
VALUE ary, dirname, basename;
|
||||
ary = rb_funcall(rb_cFile, id_split, 1, str);
|
||||
ary = rb_check_array_type(ary);
|
||||
Check_Type(ary, T_ARRAY);
|
||||
dirname = rb_ary_entry(ary, 0);
|
||||
basename = rb_ary_entry(ary, 1);
|
||||
dirname = rb_class_new_instance(1, &dirname, rb_obj_class(self));
|
||||
|
|
|
@ -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?
|
||||
|
|
Загрузка…
Ссылка в новой задаче