Permalink
Browse files

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.
  • Loading branch information...
matz committed Mar 13, 2017
1 parent 877f43b commit 191ee2596cc7b22e3213d82bab1a48ae6152b475
Showing with 4 additions and 2 deletions.
  1. +4 −2 mrbgems/mruby-object-ext/src/object.c
@@ -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);
}

0 comments on commit 191ee25

Please sign in to comment.