diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-02-24 01:31:16 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-02-24 01:31:16 +0000 |
commit | 6cbbe85481f4bc9b73d3ac773ca64d6e029c64bb (patch) | |
tree | c3775efd5a274dc1d62a0f057fdb79d3a7cff032 /vm_insnhelper.c | |
parent | 9afc6729e0d2e1aa279abf2036a02b8686379fde (diff) | |
download | ruby-6cbbe85481f4bc9b73d3ac773ca64d6e029c64bb.tar.gz |
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_2@49708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r-- | vm_insnhelper.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 3fd3100d7c..21c60af4c1 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -264,6 +264,27 @@ rb_vm_get_cref(const rb_iseq_t *iseq, const VALUE *ep) return cref; } +void +rb_vm_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); + COPY_CREF_OMOD(new_node, node); + 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); + COPY_CREF_OMOD(new_node, node); + node = node->nd_next; + *new_cref_ptr = new_node; + new_cref_ptr = &new_node->nd_next; + } + *new_cref_ptr = NULL; +} + static NODE * vm_cref_push(rb_thread_t *th, VALUE klass, int noex, rb_block_t *blockptr) { |