diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-04 23:08:32 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-04 23:08:32 +0000 |
commit | 918fefb7f71487770b538336fca0dca8d442d32e (patch) | |
tree | 19f6fec4fd8e2a420fbf9a06e6d899bdb37a3382 /vm_insnhelper.c | |
parent | a82c5ee48b805333f68b613b8eb76cd05e5a0078 (diff) |
* vm_insnhelper.c (vm_yield_setup_block_args): restores the first
arg where is overwritten at funcall. [ruby-core:24139]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23956 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r-- | vm_insnhelper.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 8412e4a77b..443b16b4ff 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -761,7 +761,7 @@ vm_yield_setup_block_args(rb_thread_t *th, const rb_iseq_t * iseq, int i; int argc = orig_argc; const int m = iseq->argc; - VALUE ary; + VALUE ary, arg0; rb_num_t opt_pc = 0; th->mark_stack_len = argc; @@ -771,15 +771,19 @@ vm_yield_setup_block_args(rb_thread_t *th, const rb_iseq_t * iseq, * => {|a|} => a = [1, 2] * => {|a, b|} => a, b = [1, 2] */ + arg0 = argv[0]; if (!(iseq->arg_simple & 0x02) && /* exclude {|a|} */ (m + iseq->arg_post_len) > 0 && /* this process is meaningful */ - argc == 1 && !NIL_P(ary = rb_check_array_type(argv[0]))) { /* rhs is only an array */ + argc == 1 && !NIL_P(ary = rb_check_array_type(arg0))) { /* rhs is only an array */ th->mark_stack_len = argc = RARRAY_LENINT(ary); CHECK_STACK_OVERFLOW(th->cfp, argc); MEMCPY(argv, RARRAY_PTR(ary), VALUE, argc); } + else { + argv[0] = arg0; + } for (i=argc; i<m; i++) { argv[i] = Qnil; |