Add `ary_modify_check()` to `Array#unshift`; ref #3737

parent e1de8613
......@@ -533,6 +533,7 @@ mrb_ary_unshift_m(mrb_state *mrb, mrb_value self)
if (ARY_SHARED_P(a)
&& a->aux.shared->refcnt == 1 /* shared only referenced from this array */
&& a->ptr - a->aux.shared->ptr >= len) /* there's room for unshifted item */ {
ary_modify_check(mrb, a);
a->ptr -= len;
}
else {
......
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