mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@929 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a509e67c5a
commit
6fc752bf7d
11 changed files with 111 additions and 78 deletions
17
variable.c
17
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue