summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2026-03-21 09:08:51 -0700
committerJohn Hawthorn <john@hawthorn.email>2026-03-25 12:51:46 -0700
commit109a20a72a6e92c7daf9dafd508b467764679d0b (patch)
tree830accd36ce092c1e1975818c08866d4464cc7a8 /proc.c
parent68cb8d8282b4bda20d8cd04b2d387a9b60418dba (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.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/proc.c b/proc.c
index 3e2afeab3c..f1fc978060 100644
--- a/proc.c
+++ b/proc.c
@@ -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);