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

This commit is contained in:
Yukihiro "Matz" Matsumoto
2017-06-27 22:29:24 +09:00
parent b30eba6a13
commit 1a3b32343e
+3 -1
View File
@@ -902,7 +902,9 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
if (argc > i) {
*pl = argc-i;
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;
arg_i += *pl;