Fix modiying class variable to frozen class/module

This commit is contained in:
KOBAYASHI Shuji
2019-04-24 21:05:44 +09:00
parent 163a6d01e0
commit 4720648137
3 changed files with 28 additions and 1 deletions
+2
View File
@@ -671,6 +671,7 @@ mrb_mod_cv_set(mrb_state *mrb, struct RClass *c, mrb_sym sym, mrb_value v)
iv_tbl *t = c->iv;
if (iv_get(mrb, t, sym, NULL)) {
mrb_check_frozen(mrb, c);
iv_put(mrb, t, sym, v);
mrb_write_barrier(mrb, (struct RBasic*)c);
return;
@@ -698,6 +699,7 @@ mrb_mod_cv_set(mrb_state *mrb, struct RClass *c, mrb_sym sym, mrb_value v)
c = cls;
}
mrb_check_frozen(mrb, c);
if (!c->iv) {
c->iv = iv_new(mrb);
}