Need to copy argv since it may be reallocated; fix #3500

The argv for `mrb_yield_with_class()` should not be on mruby stack.
Note the result from `mrb_get_args("*")` is on the stack.
parent 877f43bc
......@@ -62,10 +62,11 @@ nil_to_i(mrb_state *mrb, mrb_value obj)
static mrb_value
mrb_obj_instance_exec(mrb_state *mrb, mrb_value self)
{
mrb_value *argv;
const mrb_value *argv;
mrb_int argc;
mrb_value blk;
struct RClass *c;
mrb_value args;
mrb_get_args(mrb, "*&", &argv, &argc, &blk);
......@@ -83,7 +84,8 @@ mrb_obj_instance_exec(mrb_state *mrb, mrb_value self)
c = mrb_class_ptr(mrb_singleton_class(mrb, self));
break;
}
args = mrb_ary_new_from_values(mrb, argc, argv);
argv = RARRAY_PTR(args);
return mrb_yield_with_class(mrb, blk, argc, argv, self, c);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment