diff options
| author | Yukihiro Matsumoto <[email protected]> | 2012-07-25 08:53:49 +0900 |
|---|---|---|
| committer | Yukihiro Matsumoto <[email protected]> | 2012-07-25 08:53:49 +0900 |
| commit | 08213e32e817f83313b1586d76c0e8735ba210e7 (patch) | |
| tree | 2826521149bf16e672d9313d1d5a4035e899f23a /src | |
| parent | 88b638cf823741e3db204856e43f422229a1005c (diff) | |
| download | mruby-08213e32e817f83313b1586d76c0e8735ba210e7.tar.gz mruby-08213e32e817f83313b1586d76c0e8735ba210e7.zip | |
const reference from instance_eval should not cause SEGV
Diffstat (limited to 'src')
| -rw-r--r-- | src/variable.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/variable.c b/src/variable.c index 501bed5a6..a1a7f2e82 100644 --- a/src/variable.c +++ b/src/variable.c @@ -10,6 +10,7 @@ #include "mruby/variable.h" #include "error.h" #include "mruby/array.h" +#include "mruby/proc.h" #ifdef ENABLE_REGEXP #include "re.h" @@ -342,7 +343,10 @@ mrb_const_get(mrb_state *mrb, mrb_value mod, mrb_sym sym) mrb_value mrb_vm_const_get(mrb_state *mrb, mrb_sym sym) { - return const_get(mrb, mrb->ci->target_class, sym); + struct RClass *c = mrb->ci->proc->target_class; + + if (!c) c = mrb->ci->target_class; + return const_get(mrb, c, sym); } void @@ -355,7 +359,10 @@ mrb_const_set(mrb_state *mrb, mrb_value mod, mrb_sym sym, mrb_value v) void mrb_vm_const_set(mrb_state *mrb, mrb_sym sym, mrb_value v) { - mrb_obj_iv_set(mrb, (struct RObject*)mrb->ci->target_class, sym, v); + struct RClass *c = mrb->ci->proc->target_class; + + if (!c) c = mrb->ci->target_class; + mrb_obj_iv_set(mrb, (struct RObject*)c, sym, v); } void |
