mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* vm_method.c (rb_redefine_opt_method): use RCLASS_ORIGIN to avoid
SEGV when a module-prepended class is refined. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b361d7d082
commit
0f24f94470
3 changed files with 32 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
|||
Tue Aug 7 11:35:37 2012 Shugo Maeda <shugo@ruby-lang.org>
|
||||
|
||||
* vm_method.c (rb_redefine_opt_method): use RCLASS_ORIGIN to avoid
|
||||
SEGV when a module-prepended class is refined.
|
||||
|
||||
Tue Aug 7 10:46:37 2012 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* test/ruby/test_file_exhaustive.rb
|
||||
|
|
|
@ -300,5 +300,29 @@ class TestRefinement < Test::Unit::TestCase
|
|||
assert_equal("m2#bar", m.call_bar("abc"))
|
||||
assert_equal("m3#baz", m.call_baz("abc"))
|
||||
end
|
||||
|
||||
def test_refine_prepended_class
|
||||
m1 = Module.new {
|
||||
def foo
|
||||
super << :m1
|
||||
end
|
||||
}
|
||||
c = Class.new {
|
||||
prepend m1
|
||||
|
||||
def foo
|
||||
[:c]
|
||||
end
|
||||
}
|
||||
m2 = Module.new {
|
||||
refine c do
|
||||
def foo
|
||||
super << :m2
|
||||
end
|
||||
end
|
||||
}
|
||||
obj = c.new
|
||||
assert_equal([:c, :m1, :m2], m2.module_eval { obj.foo })
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1415,13 +1415,14 @@ rb_redefine_opt_method(VALUE klass, ID mid)
|
|||
{
|
||||
st_data_t data;
|
||||
rb_method_entry_t *me = 0;
|
||||
VALUE origin = RCLASS_ORIGIN(klass);
|
||||
|
||||
if (!st_lookup(RCLASS_M_TBL(klass), mid, &data) ||
|
||||
if (!st_lookup(RCLASS_M_TBL(origin), mid, &data) ||
|
||||
!(me = (rb_method_entry_t *)data) ||
|
||||
(!me->def || me->def->type == VM_METHOD_TYPE_UNDEF)) {
|
||||
return;
|
||||
}
|
||||
rb_vm_check_redefinition_opt_method(me, klass);
|
||||
rb_vm_check_redefinition_opt_method(me, origin);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in a new issue