summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-09-07 06:59:46 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-09-07 06:59:46 +0000
commit6fc752bf7da30898ff8e570f9354cab9419cf3cf (patch)
tree69ef1c65eafc080502ce7cb838a7d8a34904980e /variable.c
parenta509e67c5a690ad83bde66299d73bcf967f84dc1 (diff)
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@929 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/variable.c b/variable.c
index 8ed31ca8126..b37c040681f 100644
--- a/variable.c
+++ b/variable.c
@@ -1332,11 +1332,11 @@ rb_cvar_set(klass, id, val)
{
VALUE tmp;
- if (!OBJ_TAINTED(klass) && rb_safe_level() >= 4)
- rb_raise(rb_eSecurityError, "Insecure: can't modify class variable");
tmp = klass;
while (tmp) {
if (RCLASS(tmp)->iv_tbl && 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);
return;
}
@@ -1353,6 +1353,19 @@ rb_cvar_declare(klass, id, val)
ID id;
VALUE val;
{
+ VALUE tmp;
+
+ tmp = klass;
+ while (tmp) {
+ if (RCLASS(tmp)->iv_tbl && 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);
+ return;
+ }
+ tmp = RCLASS(tmp)->super;
+ }
+
mod_av_set(klass, id, val, "class variable", Qfalse);
}