Allow Object#clone to copy frozen status only; fix #4036

Copying all flags from the original object may overwrite the clone's
flags e.g. the embedded flag.
This commit is contained in:
Yukihiro "Matz" Matsumoto
2018-06-07 16:17:00 +09:00
parent cfd0c93d7d
commit 55edae0226
+1 -1
View File
@@ -348,7 +348,7 @@ mrb_obj_clone(mrb_state *mrb, mrb_value self)
mrb_field_write_barrier(mrb, (struct RBasic*)p, (struct RBasic*)p->c);
clone = mrb_obj_value(p);
init_copy(mrb, clone, self);
p->flags = mrb_obj_ptr(self)->flags;
p->flags |= mrb_obj_ptr(self)->flags & MRB_FLAG_IS_FROZEN;
return clone;
}