diff options
| author | John Hawthorn <john@hawthorn.email> | 2026-03-21 09:08:51 -0700 |
|---|---|---|
| committer | John Hawthorn <john@hawthorn.email> | 2026-03-25 12:51:46 -0700 |
| commit | 109a20a72a6e92c7daf9dafd508b467764679d0b (patch) | |
| tree | 830accd36ce092c1e1975818c08866d4464cc7a8 /proc.c | |
| parent | 68cb8d8282b4bda20d8cd04b2d387a9b60418dba (diff) | |
Don't pass singleton to TypedData_Make_Struct
We should never initialize a class with an existing singleton class
(singleton classes definitionally should not be shared).
The only cases this happened in Ruby itself is methods, which exposes a
bug that dup did not behave correctly.
Diffstat (limited to 'proc.c')
| -rw-r--r-- | proc.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -2626,7 +2626,7 @@ method_clone(VALUE self) struct METHOD *orig, *data; TypedData_Get_Struct(self, struct METHOD, &method_data_type, orig); - clone = TypedData_Make_Struct(CLASS_OF(self), struct METHOD, &method_data_type, data); + clone = TypedData_Make_Struct(rb_obj_class(self), struct METHOD, &method_data_type, data); rb_obj_clone_setup(self, clone, Qnil); RB_OBJ_WRITE(clone, &data->recv, orig->recv); RB_OBJ_WRITE(clone, &data->klass, orig->klass); @@ -2644,7 +2644,7 @@ method_dup(VALUE self) struct METHOD *orig, *data; TypedData_Get_Struct(self, struct METHOD, &method_data_type, orig); - clone = TypedData_Make_Struct(CLASS_OF(self), struct METHOD, &method_data_type, data); + clone = TypedData_Make_Struct(rb_obj_class(self), struct METHOD, &method_data_type, data); rb_obj_dup_setup(self, clone); RB_OBJ_WRITE(clone, &data->recv, orig->recv); RB_OBJ_WRITE(clone, &data->klass, orig->klass); |
