Copy argv from VM stack to avoid use-after-free; fix #3722

parent b30eba6a
...@@ -902,7 +902,9 @@ mrb_get_args(mrb_state *mrb, const char *format, ...) ...@@ -902,7 +902,9 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
if (argc > i) { if (argc > i) {
*pl = argc-i; *pl = argc-i;
if (*pl > 0) { if (*pl > 0) {
*var = ARGV + arg_i; mrb_value args = mrb_ary_new_from_values(mrb, *pl, ARGV+arg_i);
RARRAY(args)->c = NULL;
*var = (mrb_value*)RARRAY_PTR(args);
} }
i = argc; i = argc;
arg_i += *pl; arg_i += *pl;
......
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