diff options
author | Jean Boussier <[email protected]> | 2024-04-16 15:30:00 +0200 |
---|---|---|
committer | Jean Boussier <[email protected]> | 2024-04-16 17:20:35 +0200 |
commit | f06670c5a2a1daa6595018858d5cfa429a8aeae6 (patch) | |
tree | f41c57d0089600f9faf5379d61d0aad6fbbaadee /struct.c | |
parent | 7380e3d30ff3d33fa7dd3756929e5718be665bba (diff) |
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.
Diffstat (limited to 'struct.c')
-rw-r--r-- | struct.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -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; } |