diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-02-25 06:26:48 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-02-25 06:26:48 +0000 |
commit | 852d56ff805dc0c266fb9643b24db4819898ad87 (patch) | |
tree | 7e00d1eec021201935748a8362035f67cca4e385 /class.c | |
parent | 94ec0a64197ab7a0edfb6599074df0a2920607e4 (diff) |
merge revision(s) 49685,49687: [Backport #10885]
* 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.
of original crefs. It fixes segmentation fault when calling
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@49739 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'class.c')
-rw-r--r-- | class.c | 20 |
1 files changed, 2 insertions, 18 deletions
@@ -121,32 +121,16 @@ rb_class_new(VALUE super) return rb_class_boot(super); } -static NODE* -rewrite_cref_stack(NODE *node, VALUE old_klass, VALUE new_klass) -{ - NODE *new_node; - if (!node) { - return NULL; - } - if (node->nd_clss == old_klass) { - new_node = NEW_CREF(new_klass); - new_node->nd_next = node->nd_next; - } else { - new_node = NEW_CREF(node->nd_clss); - new_node->nd_next = rewrite_cref_stack(node->nd_next, old_klass, new_klass); - } - return new_node; -} - static void clone_method(VALUE klass, ID mid, const rb_method_entry_t *me) { VALUE newiseqval; if (me->def && me->def->type == VM_METHOD_TYPE_ISEQ) { rb_iseq_t *iseq; + NODE *new_cref; newiseqval = rb_iseq_clone(me->def->body.iseq->self, klass); GetISeqPtr(newiseqval, iseq); - iseq->cref_stack = rewrite_cref_stack(me->def->body.iseq->cref_stack, me->klass, klass); + rb_vm_rewrite_cref_stack(me->def->body.iseq->cref_stack, me->klass, klass, &new_cref); rb_add_method(klass, mid, VM_METHOD_TYPE_ISEQ, iseq, me->flag); RB_GC_GUARD(newiseqval); } |