mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Merge pull request #3972 from take-cheeze/fix_ary_set_len_assert
Set array length after expanding capacity.
This commit is contained in:
+1
-1
@@ -256,7 +256,6 @@ mrb_ary_resize(mrb_state *mrb, mrb_value ary, mrb_int new_len)
|
||||
ary_modify(mrb, a);
|
||||
old_len = RARRAY_LEN(ary);
|
||||
if (old_len != new_len) {
|
||||
ARY_SET_LEN(a, new_len);
|
||||
if (new_len < old_len) {
|
||||
ary_shrink_capa(mrb, a);
|
||||
}
|
||||
@@ -264,6 +263,7 @@ mrb_ary_resize(mrb_state *mrb, mrb_value ary, mrb_int new_len)
|
||||
ary_expand_capa(mrb, a, new_len);
|
||||
ary_fill_with_nil(ARY_PTR(a) + old_len, new_len - old_len);
|
||||
}
|
||||
ARY_SET_LEN(a, new_len);
|
||||
}
|
||||
|
||||
return ary;
|
||||
|
||||
Reference in New Issue
Block a user