1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Don't attempt to read ivars on T_ICLASS in struct (#5664)

This commit is contained in:
John Hawthorn 2022-05-26 11:54:15 -07:00 committed by GitHub
parent c3929b8c73
commit adc709adb8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: git 2022-05-27 03:54:39 +09:00
Merged-By: jhawthorn <john@hawthorn.email>

View file

@ -43,13 +43,14 @@ struct_ivar_get(VALUE c, ID id)
return ivar; return ivar;
for (;;) { for (;;) {
c = RCLASS_SUPER(c); c = rb_class_superclass(c);
if (c == 0 || c == rb_cStruct) if (c == 0 || c == rb_cStruct)
return Qnil; return Qnil;
ivar = rb_attr_get(c, id); RUBY_ASSERT(RB_TYPE_P(c, T_CLASS));
if (!NIL_P(ivar)) { ivar = rb_attr_get(c, id);
return rb_ivar_set(orig, id, ivar); if (!NIL_P(ivar)) {
} return rb_ivar_set(orig, id, ivar);
}
} }
} }