diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-17 12:25:47 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-17 12:25:47 +0000 |
commit | b982cff67c1e7e879b4532f496c40d9ebd3b1c0d (patch) | |
tree | 9f8d1c255a53e591b22b132f3dbf0f30ffd9dbeb /insnhelper.ci | |
parent | e5d5f5a61a484c5d3993cee2c02c4f501a6f74f8 (diff) | |
download | ruby-b982cff67c1e7e879b4532f496c40d9ebd3b1c0d.tar.gz |
* eval.c (rb_call), eval_method.ci (rb_add_method, rb_alias),
insnhelper.ci (vm_call_method): fix to save safelevel for
method node.
* include/ruby/node.h: ditto.
* bootstraptest/test_method.rb: add a test for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'insnhelper.ci')
-rw-r--r-- | insnhelper.ci | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/insnhelper.ci b/insnhelper.ci index bb87a432a7..8f71703cb6 100644 --- a/insnhelper.ci +++ b/insnhelper.ci @@ -487,23 +487,31 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, val = vm_method_missing(th, id, recv, num, blockptr, stat); } } - else if (!(flag & VM_CALL_FCALL_BIT) && - (mn->nd_noex & NOEX_MASK) & NOEX_PRIVATE) { - int stat = NOEX_PRIVATE; - if (flag & VM_CALL_VCALL_BIT) { - stat |= NOEX_VCALL; + else if (UNLIKELY(mn->nd_noex)) { + if (!(flag & VM_CALL_FCALL_BIT) && + (mn->nd_noex & NOEX_MASK) & NOEX_PRIVATE) { + int stat = NOEX_PRIVATE; + if (flag & VM_CALL_VCALL_BIT) { + stat |= NOEX_VCALL; + } + val = vm_method_missing(th, id, recv, num, blockptr, stat); } - val = vm_method_missing(th, id, recv, num, blockptr, stat); - } - else if ((mn->nd_noex & NOEX_MASK) & NOEX_PROTECTED) { - VALUE defined_class = mn->nd_clss; + else if ((mn->nd_noex & NOEX_MASK) & NOEX_PROTECTED) { + VALUE defined_class = mn->nd_clss; - if (TYPE(defined_class) == T_ICLASS) { - defined_class = RBASIC(defined_class)->klass; - } + if (TYPE(defined_class) == T_ICLASS) { + defined_class = RBASIC(defined_class)->klass; + } - if (!rb_obj_is_kind_of(cfp->self, rb_class_real(defined_class))) { - val = vm_method_missing(th, id, recv, num, blockptr, NOEX_PROTECTED); + if (!rb_obj_is_kind_of(cfp->self, rb_class_real(defined_class))) { + val = vm_method_missing(th, id, recv, num, blockptr, NOEX_PROTECTED); + } + else { + goto normal_method_dispatch; + } + } + else if (NOEX_SAFE(mn->nd_noex) > th->safe_level) { + rb_raise(rb_eSecurityError, "calling insecure method: %s", rb_id2name(id)); } else { goto normal_method_dispatch; |