Commit 1fdf47d7 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #2582 from iij/pr-attr-accessor-save-arena

save and restore arena index to prevent arena overflow.
parents f6e7de5f 2fd49b2b
......@@ -1069,8 +1069,10 @@ mrb_mod_attr_reader(mrb_state *mrb, mrb_value mod)
struct RClass *c = mrb_class_ptr(mod);
mrb_value *argv;
mrb_int argc, i;
int ai;
mrb_get_args(mrb, "*", &argv, &argc);
ai = mrb_gc_arena_save(mrb);
for (i=0; i<argc; i++) {
mrb_value name, str;
mrb_sym method, sym;
......@@ -1085,6 +1087,7 @@ mrb_mod_attr_reader(mrb_state *mrb, mrb_value mod)
name = mrb_symbol_value(sym);
mrb_define_method_raw(mrb, c, method,
mrb_proc_new_cfunc_with_env(mrb, attr_reader, 1, &name));
mrb_gc_arena_restore(mrb, ai);
}
return mrb_nil_value();
}
......@@ -1106,8 +1109,10 @@ mrb_mod_attr_writer(mrb_state *mrb, mrb_value mod)
struct RClass *c = mrb_class_ptr(mod);
mrb_value *argv;
mrb_int argc, i;
int ai;
mrb_get_args(mrb, "*", &argv, &argc);
ai = mrb_gc_arena_save(mrb);
for (i=0; i<argc; i++) {
mrb_value name, str, attr;
mrb_sym method, sym;
......@@ -1131,6 +1136,7 @@ mrb_mod_attr_writer(mrb_state *mrb, mrb_value mod)
mrb_define_method_raw(mrb, c, method,
mrb_proc_new_cfunc_with_env(mrb, attr_writer, 1, &attr));
mrb_gc_arena_restore(mrb, ai);
}
return mrb_nil_value();
}
......
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