diff options
author | Peter Zhu <peter@peterzhu.ca> | 2023-11-20 10:13:18 -0500 |
---|---|---|
committer | Peter Zhu <peter@peterzhu.ca> | 2023-11-20 10:13:18 -0500 |
commit | 83da4a7e6291fbc919c1a5813f3e84b8fdd858d5 (patch) | |
tree | d89224048ab17587f925e8d105964d1a9e1c5597 | |
parent | 4dd11c067da85aa8af1b712d76f51d42ce2cee6f (diff) | |
download | ruby-83da4a7e6291fbc919c1a5813f3e84b8fdd858d5.tar.gz |
Fix crash when iterating over generic ivars
-rw-r--r-- | test/ruby/test_shapes.rb | 2 | ||||
-rw-r--r-- | variable.c | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/test/ruby/test_shapes.rb b/test/ruby/test_shapes.rb index f985f8c611..bcb6791a05 100644 --- a/test/ruby/test_shapes.rb +++ b/test/ruby/test_shapes.rb @@ -207,6 +207,8 @@ class TestShapes < Test::Unit::TestCase tc.instance_variable_set(:@very_unique2, 4) assert_equal 3, tc.instance_variable_get(:@very_unique) assert_equal 4, tc.instance_variable_get(:@very_unique2) + + assert_equal [:@very_unique, :@very_unique2], tc.instance_variables end; end diff --git a/variable.c b/variable.c index 7935162098..8258754e3f 100644 --- a/variable.c +++ b/variable.c @@ -1951,7 +1951,7 @@ gen_ivar_each(VALUE obj, rb_ivar_foreach_callback_func *func, st_data_t arg) itr_data.arg = arg; itr_data.func = func; if (rb_shape_obj_too_complex(obj)) { - rb_st_foreach((st_table *)ivtbl, each_hash_iv, (st_data_t)&itr_data); + rb_st_foreach(ivtbl->as.complex.table, each_hash_iv, (st_data_t)&itr_data); } else { iterate_over_shapes_with_callback(shape, func, &itr_data); |