array.c (mrb_ary_push_m): adjust function order.
ary_modify() and ary_expand_capa() may cause garbage collection and may
make argv invalid (in the future).
@@ -543,15 +543,15 @@ mrb_ary_push_m(mrb_state *mrb, mrb_value self)
mrb_int len, len2;
struct RArray *a;
+ ary_modify(mrb, a);
argc = mrb_get_argc(mrb);
- argv = mrb_get_argv(mrb);
a = mrb_ary_ptr(self);
- ary_modify(mrb, a);
len = ARY_LEN(a);
len2 = len + argc;
if (ARY_CAPA(a) < len2) {
ary_expand_capa(mrb, a, len2);
}
+ argv = mrb_get_argv(mrb);
array_copy(ARY_PTR(a)+len, argv, argc);
ARY_SET_LEN(a, len2);
while (argc--) {
