summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/variable.c b/variable.c
index ce8180f02f..8b9dfaa1d5 100644
--- a/variable.c
+++ b/variable.c
@@ -1459,16 +1459,15 @@ rb_cvar_set(klass, id, val)
tmp = klass;
while (tmp) {
- if (RCLASS(tmp)->iv_tbl) {
- if (st_lookup(RCLASS(tmp)->iv_tbl,id,0)) {
- if (!OBJ_TAINTED(tmp) && rb_safe_level() >= 4)
- rb_raise(rb_eSecurityError, "Insecure: can't modify class variable");
- st_insert(RCLASS(tmp)->iv_tbl,id,val);
- if (ruby_verbose) {
- cvar_override_check(id, tmp);
- }
- return;
+ if (RCLASS(tmp)->iv_tbl && st_lookup(RCLASS(tmp)->iv_tbl,id,0)) {
+ if (OBJ_FROZEN(tmp)) rb_error_frozen("class/module");
+ if (!OBJ_TAINTED(tmp) && rb_safe_level() >= 4)
+ rb_raise(rb_eSecurityError, "Insecure: can't modify class variable");
+ st_insert(RCLASS(tmp)->iv_tbl,id,val);
+ if (ruby_verbose) {
+ cvar_override_check(id, tmp);
}
+ return;
}
tmp = RCLASS(tmp)->super;
}
@@ -1488,6 +1487,7 @@ rb_cvar_declare(klass, id, val)
tmp = klass;
while (tmp) {
if (RCLASS(tmp)->iv_tbl && st_lookup(RCLASS(tmp)->iv_tbl,id,0)) {
+ if (OBJ_FROZEN(tmp)) rb_error_frozen("class/module");
if (!OBJ_TAINTED(tmp) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't modify class variable");
if (ruby_verbose && klass != tmp) {