aboutsummaryrefslogtreecommitdiffstats
path: root/variable.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-08-17 22:57:40 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-08-17 22:57:40 +0900
commitb52a501ca786a54fdaadf1a60fef517c55dd6ca3 (patch)
tree83a9d5e70f9f52f4c03fbda2f00ce286b0ee2603 /variable.c
parent27f7b047e07ceb9ee963e5d74ab0399b5e94ac4c (diff)
downloadruby-b52a501ca786a54fdaadf1a60fef517c55dd6ca3.tar.gz
Ensure the shortcut cached in the class
As well as the other places using RCLASS_IV_INDEX_TBL. `IO#reopen` seems the only case that the class of an object can be changed.
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/variable.c b/variable.c
index 56340820f3..4f66ad3e7f 100644
--- a/variable.c
+++ b/variable.c
@@ -885,7 +885,7 @@ generic_ivar_delete(VALUE obj, ID id, VALUE undef)
st_table *iv_index_tbl = RCLASS_IV_INDEX_TBL(rb_obj_class(obj));
st_data_t index;
- if (st_lookup(iv_index_tbl, (st_data_t)id, &index)) {
+ if (iv_index_tbl && st_lookup(iv_index_tbl, (st_data_t)id, &index)) {
if (index < ivtbl->numiv) {
VALUE ret = ivtbl->ivptr[index];
@@ -906,7 +906,7 @@ generic_ivar_get(VALUE obj, ID id, VALUE undef)
st_table *iv_index_tbl = RCLASS_IV_INDEX_TBL(rb_obj_class(obj));
st_data_t index;
- if (st_lookup(iv_index_tbl, (st_data_t)id, &index)) {
+ if (iv_index_tbl && st_lookup(iv_index_tbl, (st_data_t)id, &index)) {
if (index < ivtbl->numiv) {
VALUE ret = ivtbl->ivptr[index];