summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
authorktsj <ktsj@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-22 07:05:14 (GMT)
committerktsj <ktsj@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-22 07:05:14 (GMT)
commite660f776c04342d353a994ee6392a37ffed6cbfe (patch)
tree907dc211d37b85656dba9e63f10d07f50e5f13fe /class.c
parent513fefdd1f0feb68fe4bd9a233dd1cbfeb7390ba (diff)
* vm_insnhelper.c (rb_vm_rewrite_cref_stack): copy nd_refinements
of orignal crefs. It fixes segmentation fault when calling refined method in duplicate module. [ruby-dev:48878] [Bug #10885] * vm_core.h, class.c: change accordingly. * test/ruby/test_refinement.rb: add a test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'class.c')
-rw-r--r--class.c21
1 files changed, 1 insertions, 20 deletions
diff --git a/class.c b/class.c
index 373919b..c2657f2 100644
--- a/class.c
+++ b/class.c
@@ -241,25 +241,6 @@ rb_class_new(VALUE super)
}
static void
-rewrite_cref_stack(NODE *node, VALUE old_klass, VALUE new_klass, NODE **new_cref_ptr)
-{
- NODE *new_node;
- while (node) {
- if (node->nd_clss == old_klass) {
- new_node = NEW_CREF(new_klass);
- RB_OBJ_WRITE(new_node, &new_node->nd_next, node->nd_next);
- *new_cref_ptr = new_node;
- return;
- }
- new_node = NEW_CREF(node->nd_clss);
- node = node->nd_next;
- *new_cref_ptr = new_node;
- new_cref_ptr = &new_node->nd_next;
- }
- *new_cref_ptr = NULL;
-}
-
-static void
clone_method(VALUE klass, ID mid, const rb_method_entry_t *me)
{
VALUE newiseqval;
@@ -268,7 +249,7 @@ clone_method(VALUE klass, ID mid, const rb_method_entry_t *me)
NODE *new_cref;
newiseqval = rb_iseq_clone(me->def->body.iseq->self, klass);
GetISeqPtr(newiseqval, iseq);
- rewrite_cref_stack(me->def->body.iseq->cref_stack, me->klass, klass, &new_cref);
+ rb_vm_rewrite_cref_stack(me->def->body.iseq->cref_stack, me->klass, klass, &new_cref);
RB_OBJ_WRITE(iseq->self, &iseq->cref_stack, new_cref);
rb_add_method(klass, mid, VM_METHOD_TYPE_ISEQ, iseq, me->flag);
RB_GC_GUARD(newiseqval);