aboutsummaryrefslogtreecommitdiffstats
path: root/variable.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-02-11 11:28:31 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-02-12 15:05:29 +0900
commit52cdf400efaecc0f5e1d1f70f22dc45212e03c4c (patch)
tree162768d517e60c8bba893936bfce8b77ab55caca /variable.c
parent921916ff9e2940f28d932af84c5b2a2e222219d0 (diff)
downloadruby-52cdf400efaecc0f5e1d1f70f22dc45212e03c4c.tar.gz
Workaround of instance variable on hidden object
Since 9d9aea7fe50f6340829faa105d9ffe08ebaee658, generic instance variables need `iv_index_tbl` in the object's class. As hidden objects, however, have no class, access to the variables causes a segfault. Get rid of that segfault by raising an exception, for the time being.
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/variable.c b/variable.c
index 646d60d6eb..2dba76668b 100644
--- a/variable.c
+++ b/variable.c
@@ -1134,9 +1134,12 @@ static st_table *
iv_index_tbl_make(VALUE obj)
{
VALUE klass = rb_obj_class(obj);
- st_table *iv_index_tbl = RCLASS_IV_INDEX_TBL(klass);
+ st_table *iv_index_tbl;
- if (!iv_index_tbl) {
+ if (!klass) {
+ rb_raise(rb_eTypeError, "hidden object cannot have instance variables");
+ }
+ if (!(iv_index_tbl = RCLASS_IV_INDEX_TBL(klass))) {
iv_index_tbl = RCLASS_IV_INDEX_TBL(klass) = st_init_numtable();
}