ruby-changes:71973
From: John <ko1@a...>
Date: Fri, 27 May 2022 03:54:32 +0900 (JST)
Subject: [ruby-changes:71973] adc709adb8 (master): Don't attempt to read ivars on T_ICLASS in struct (#5664)
https://git.ruby-lang.org/ruby.git/commit/?id=adc709adb8 From adc709adb8c7fbe83a20b7c9b554856c98346a4b Mon Sep 17 00:00:00 2001 From: John Hawthorn <john@h...> Date: Thu, 26 May 2022 11:54:15 -0700 Subject: Don't attempt to read ivars on T_ICLASS in struct (#5664) --- struct.c | 15 ++++++++------- 1 file 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) https://github.com/ruby/ruby/blob/trunk/struct.c#L43 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); + } } } -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/