summaryrefslogtreecommitdiffstats
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-04 23:08:32 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-04 23:08:32 +0000
commitf4691c87092590cc068d1df19b79a7e3b38826d2 (patch)
tree19f6fec4fd8e2a420fbf9a06e6d899bdb37a3382 /vm_insnhelper.c
parent8d96bc5e2ddb03e4e9c83cb6aae4bf010f89b7d4 (diff)
downloadruby-f4691c87092590cc068d1df19b79a7e3b38826d2.tar.gz
ruby-f4691c87092590cc068d1df19b79a7e3b38826d2.tar.xz
ruby-f4691c87092590cc068d1df19b79a7e3b38826d2.zip
* vm_insnhelper.c (vm_yield_setup_block_args): restores the first
arg where is overwritten at funcall. [ruby-core:24139] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@23956 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 8412e4a77..443b16b4f 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;