Unverified Commit e581f2ed authored by ksss's avatar ksss

Should only check frozen fix #3737

parent ce6c0560
...@@ -106,11 +106,17 @@ ary_fill_with_nil(mrb_value *ptr, mrb_int size) ...@@ -106,11 +106,17 @@ ary_fill_with_nil(mrb_value *ptr, mrb_int size)
} }
static void static void
ary_modify(mrb_state *mrb, struct RArray *a) ary_modify_check(mrb_state *mrb, struct RArray *a)
{ {
if (MRB_FROZEN_P(a)) { if (MRB_FROZEN_P(a)) {
mrb_raise(mrb, E_RUNTIME_ERROR, "can't modify frozen array"); mrb_raise(mrb, E_RUNTIME_ERROR, "can't modify frozen array");
} }
}
static void
ary_modify(mrb_state *mrb, struct RArray *a)
{
ary_modify_check(mrb, a);
if (ARY_SHARED_P(a)) { if (ARY_SHARED_P(a)) {
mrb_shared_array *shared = a->aux.shared; mrb_shared_array *shared = a->aux.shared;
...@@ -458,7 +464,7 @@ mrb_ary_shift(mrb_state *mrb, mrb_value self) ...@@ -458,7 +464,7 @@ mrb_ary_shift(mrb_state *mrb, mrb_value self)
struct RArray *a = mrb_ary_ptr(self); struct RArray *a = mrb_ary_ptr(self);
mrb_value val; mrb_value val;
ary_modify(mrb, a); ary_modify_check(mrb, a);
if (a->len == 0) return mrb_nil_value(); if (a->len == 0) return mrb_nil_value();
if (ARY_SHARED_P(a)) { if (ARY_SHARED_P(a)) {
L_SHIFT: L_SHIFT:
......
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