mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
[Feature #19163] Data object should be frozen
This commit is contained in:
parent
06a0c58016
commit
a14a1a5626
Notes:
git
2022-12-01 15:57:12 +00:00
2 changed files with 19 additions and 1 deletions
12
struct.c
12
struct.c
|
@ -1818,9 +1818,19 @@ rb_data_initialize_m(int argc, const VALUE *argv, VALUE self)
|
|||
if (arg.unknown_keywords != Qnil) {
|
||||
rb_exc_raise(rb_keyword_error_new("unknown", arg.unknown_keywords));
|
||||
}
|
||||
OBJ_FREEZE_RAW(self);
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
/* :nodoc: */
|
||||
static VALUE
|
||||
rb_data_init_copy(VALUE copy, VALUE s)
|
||||
{
|
||||
copy = rb_struct_init_copy(copy, s);
|
||||
RB_OBJ_FREEZE_RAW(copy);
|
||||
return copy;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* inspect -> string
|
||||
|
@ -2180,7 +2190,7 @@ InitVM_Struct(void)
|
|||
#endif
|
||||
|
||||
rb_define_method(rb_cData, "initialize", rb_data_initialize_m, -1);
|
||||
rb_define_method(rb_cData, "initialize_copy", rb_struct_init_copy, 1);
|
||||
rb_define_method(rb_cData, "initialize_copy", rb_data_init_copy, 1);
|
||||
|
||||
rb_define_method(rb_cData, "==", rb_data_equal, 1);
|
||||
rb_define_method(rb_cData, "eql?", rb_data_eql, 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue