From 671b498070c0fa33fa6afaf4f4672441ae61661a Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 19 Oct 2010 03:25:29 +0000 Subject: Commit miss. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- variable.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'variable.c') diff --git a/variable.c b/variable.c index 46717e73c4..ce5c2b8258 100644 --- a/variable.c +++ b/variable.c @@ -1043,7 +1043,7 @@ rb_ivar_set(VALUE obj, ID id, VALUE val) if (!OBJ_UNTRUSTED(obj) && rb_safe_level() >= 4) rb_raise(rb_eSecurityError, "Insecure: can't modify instance variable"); - rb_check_frozen(obj); + if (OBJ_FROZEN(obj)) rb_error_frozen("object"); switch (TYPE(obj)) { case T_OBJECT: iv_index_tbl = ROBJECT_IV_INDEX_TBL(obj); @@ -1305,7 +1305,7 @@ rb_obj_remove_instance_variable(VALUE obj, VALUE name) if (!OBJ_UNTRUSTED(obj) && rb_safe_level() >= 4) rb_raise(rb_eSecurityError, "Insecure: can't modify instance variable"); - rb_check_frozen(obj); + if (OBJ_FROZEN(obj)) rb_error_frozen("object"); if (!rb_is_instance_id(id)) { rb_name_error(id, "`%s' is not allowed as an instance variable name", rb_id2name(id)); } @@ -1653,7 +1653,8 @@ rb_const_remove(VALUE mod, ID id) if (!OBJ_UNTRUSTED(mod) && rb_safe_level() >= 4) rb_raise(rb_eSecurityError, "Insecure: can't remove constant"); - rb_check_frozen(mod); + if (OBJ_FROZEN(mod)) rb_error_frozen("class/module"); + if (!RCLASS_IV_TBL(mod) || !st_delete(RCLASS_IV_TBL(mod), &n, &v)) { if (rb_const_defined_at(mod, id)) { rb_name_error(id, "cannot remove %s::%s", @@ -1818,7 +1819,14 @@ mod_av_set(VALUE klass, ID id, VALUE val, int isconst) if (!OBJ_UNTRUSTED(klass) && rb_safe_level() >= 4) rb_raise(rb_eSecurityError, "Insecure: can't set %s", dest); - rb_check_frozen(klass); + if (OBJ_FROZEN(klass)) { + if (BUILTIN_TYPE(klass) == T_MODULE) { + rb_error_frozen("module"); + } + else { + rb_error_frozen("class"); + } + } if (!RCLASS_IV_TBL(klass)) { RCLASS_IV_TBL(klass) = st_init_numtable(); } @@ -2067,7 +2075,8 @@ rb_mod_remove_cvar(VALUE mod, VALUE name) } if (!OBJ_UNTRUSTED(mod) && rb_safe_level() >= 4) rb_raise(rb_eSecurityError, "Insecure: can't remove class variable"); - rb_check_frozen(mod); + if (OBJ_FROZEN(mod)) rb_error_frozen("class/module"); + if (RCLASS_IV_TBL(mod) && st_delete(RCLASS_IV_TBL(mod), &n, &val)) { return (VALUE)val; } -- cgit v1.2.3