mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Eliminate usage of OBJ_FREEZE_RAW
Previously it would bypass the `FL_ABLE` check, but since shapes introduction, it started having a different behavior than `OBJ_FREEZE`, as it would onyl set the `FL_FREEZE` flag, but not update the shape. I have no indication of this causing a bug yet, but it seems like a trap waiting to happen.
This commit is contained in:
parent
7380e3d30f
commit
f06670c5a2
9 changed files with 22 additions and 22 deletions
14
struct.c
14
struct.c
|
@ -136,7 +136,7 @@ struct_set_members(VALUE klass, VALUE /* frozen hidden array */ members)
|
|||
j = struct_member_pos_probe(j, mask);
|
||||
}
|
||||
}
|
||||
OBJ_FREEZE_RAW(back);
|
||||
OBJ_FREEZE(back);
|
||||
}
|
||||
rb_ivar_set(klass, id_members, members);
|
||||
rb_ivar_set(klass, id_back_members, back);
|
||||
|
@ -422,7 +422,7 @@ struct_make_members_list(va_list ar)
|
|||
}
|
||||
ary = rb_hash_keys(list);
|
||||
RBASIC_CLEAR_CLASS(ary);
|
||||
OBJ_FREEZE_RAW(ary);
|
||||
OBJ_FREEZE(ary);
|
||||
return ary;
|
||||
}
|
||||
|
||||
|
@ -682,7 +682,7 @@ rb_struct_s_def(int argc, VALUE *argv, VALUE klass)
|
|||
}
|
||||
rest = rb_hash_keys(rest);
|
||||
RBASIC_CLEAR_CLASS(rest);
|
||||
OBJ_FREEZE_RAW(rest);
|
||||
OBJ_FREEZE(rest);
|
||||
if (NIL_P(name)) {
|
||||
st = anonymous_struct(klass);
|
||||
}
|
||||
|
@ -794,7 +794,7 @@ VALUE
|
|||
rb_struct_initialize(VALUE self, VALUE values)
|
||||
{
|
||||
rb_struct_initialize_m(RARRAY_LENINT(values), RARRAY_CONST_PTR(values), self);
|
||||
if (rb_obj_is_kind_of(self, rb_cData)) OBJ_FREEZE_RAW(self);
|
||||
if (rb_obj_is_kind_of(self, rb_cData)) OBJ_FREEZE(self);
|
||||
RB_GC_GUARD(values);
|
||||
return Qnil;
|
||||
}
|
||||
|
@ -1685,7 +1685,7 @@ rb_data_s_def(int argc, VALUE *argv, VALUE klass)
|
|||
}
|
||||
rest = rb_hash_keys(rest);
|
||||
RBASIC_CLEAR_CLASS(rest);
|
||||
OBJ_FREEZE_RAW(rest);
|
||||
OBJ_FREEZE(rest);
|
||||
data_class = anonymous_struct(klass);
|
||||
setup_data(data_class, rest);
|
||||
if (rb_block_given_p()) {
|
||||
|
@ -1802,7 +1802,7 @@ rb_data_initialize_m(int argc, const VALUE *argv, VALUE self)
|
|||
rb_hash_foreach(argv[0], struct_hash_set_i, (VALUE)&arg);
|
||||
// Freeze early before potentially raising, so that we don't leave an
|
||||
// unfrozen copy on the heap, which could get exposed via ObjectSpace.
|
||||
OBJ_FREEZE_RAW(self);
|
||||
OBJ_FREEZE(self);
|
||||
if (arg.unknown_keywords != Qnil) {
|
||||
rb_exc_raise(rb_keyword_error_new("unknown", arg.unknown_keywords));
|
||||
}
|
||||
|
@ -1814,7 +1814,7 @@ static VALUE
|
|||
rb_data_init_copy(VALUE copy, VALUE s)
|
||||
{
|
||||
copy = rb_struct_init_copy(copy, s);
|
||||
RB_OBJ_FREEZE_RAW(copy);
|
||||
RB_OBJ_FREEZE(copy);
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue