summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-24 14:04:31 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-24 14:04:31 +0000
commit20c38381a84ea496675d514449f57583c413165c (patch)
tree4fd36277dfa704874ffae20d544de3a06b716a3d
parentfb725a20e2b3b509de44c85dd8ed83a21743b08e (diff)
vm.c: check cbase
* vm.c (rb_vm_cref_in_context): check also cbase, not only self. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44385 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--proc.c6
-rw-r--r--vm.c9
2 files changed, 9 insertions, 6 deletions
diff --git a/proc.c b/proc.c
index f8b2e3b..2630df1 100644
--- a/proc.c
+++ b/proc.c
@@ -14,7 +14,7 @@
#include "gc.h"
#include "iseq.h"
-NODE *rb_vm_cref_in_context(VALUE self);
+const NODE *rb_vm_cref_in_context(VALUE self, VALUE cbase);
struct METHOD {
VALUE recv;
@@ -1622,9 +1622,9 @@ rb_mod_define_method(int argc, VALUE *argv, VALUE mod)
ID id;
VALUE body;
int noex = NOEX_PUBLIC;
- const NODE *cref = rb_vm_cref_in_context(mod);
+ const NODE *cref = rb_vm_cref_in_context(mod, mod);
- if (cref && cref->nd_clss == mod) {
+ if (cref) {
noex = (int)cref->nd_visi;
}
diff --git a/vm.c b/vm.c
index 947b181..bd0d656 100644
--- a/vm.c
+++ b/vm.c
@@ -930,13 +930,16 @@ rb_vm_cref(void)
return rb_vm_get_cref(cfp->iseq, cfp->ep);
}
-NODE *
-rb_vm_cref_in_context(VALUE self)
+const NODE *
+rb_vm_cref_in_context(VALUE self, VALUE cbase)
{
rb_thread_t *th = GET_THREAD();
const rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->cfp);
+ const NODE *cref;
if (cfp->self != self) return NULL;
- return rb_vm_get_cref(cfp->iseq, cfp->ep);
+ cref = rb_vm_get_cref(cfp->iseq, cfp->ep);
+ if (cref->nd_clss != cbase) return NULL;
+ return cref;
}
#if 0