summaryrefslogtreecommitdiff
path: root/struct.c
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2022-05-26 11:54:15 -0700
committerGitHub <noreply@github.com>2022-05-26 11:54:15 -0700
commitadc709adb8c7fbe83a20b7c9b554856c98346a4b (patch)
tree9a5b720eb47b37efd520235aadfaa4bfa0add470 /struct.c
parentc3929b8c73d2281d2500dc9de67068ad2d2d1551 (diff)
Don't attempt to read ivars on T_ICLASS in struct (#5664)
Notes
Notes: Merged-By: jhawthorn <john@hawthorn.email>
Diffstat (limited to 'struct.c')
-rw-r--r--struct.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/struct.c b/struct.c
index 44ca389f04..c95c88200b 100644
--- a/struct.c
+++ b/struct.c
@@ -43,13 +43,14 @@ struct_ivar_get(VALUE c, ID id)
return ivar;
for (;;) {
- c = RCLASS_SUPER(c);
- if (c == 0 || c == rb_cStruct)
- return Qnil;
- ivar = rb_attr_get(c, id);
- if (!NIL_P(ivar)) {
- return rb_ivar_set(orig, id, ivar);
- }
+ c = rb_class_superclass(c);
+ if (c == 0 || c == rb_cStruct)
+ return Qnil;
+ RUBY_ASSERT(RB_TYPE_P(c, T_CLASS));
+ ivar = rb_attr_get(c, id);
+ if (!NIL_P(ivar)) {
+ return rb_ivar_set(orig, id, ivar);
+ }
}
}