Add more checks before accessing struct pointer; ref #3831

parent be2c1592
......@@ -147,11 +147,13 @@ static mrb_value
mrb_struct_set_m(mrb_state *mrb, mrb_value obj)
{
mrb_int i = mrb_fixnum(mrb_proc_cfunc_env_get(mrb, 0));
mrb_value *ptr = RSTRUCT_PTR(obj);
mrb_value *ptr;
mrb_value val;
mrb_get_args(mrb, "o", &val);
mrb_struct_modify(mrb, obj);
if (i >= RSTRUCT_LEN(obj)) {
ptr = RSTRUCT_PTR(obj);
if (ptr == NULL || i >= RSTRUCT_LEN(obj)) {
mrb_ary_set(mrb, obj, i, val);
}
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