summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2015-04-27 00:53:08 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2015-04-27 00:53:08 +0900
commitbdb9d4d19c3120666aae2ae24602f2d5dec19bbd (patch)
treefd5cad5b08d60d92ca02f26e965bc4ca22c33024 /src
parentb3b6fe3c073199dd201b95b76e0a99fcda80cdd9 (diff)
downloadmruby-bdb9d4d19c3120666aae2ae24602f2d5dec19bbd.tar.gz
mruby-bdb9d4d19c3120666aae2ae24602f2d5dec19bbd.zip
super should not be called outside of a method; fix #2770
Diffstat (limited to 'src')
-rw-r--r--src/vm.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/vm.c b/src/vm.c
index 31b80c972..181a37158 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -1222,6 +1222,13 @@ RETRY_TRY_BLOCK:
int a = GETARG_A(i);
int n = GETARG_C(i);
+ if (mid == 0) {
+ mrb_value exc;
+ out_super:
+ exc = mrb_exc_new_str_lit(mrb, E_NOMETHOD_ERROR, "super called outside of method");
+ mrb->exc = mrb_obj_ptr(exc);
+ goto L_RAISE;
+ }
recv = regs[0];
c = mrb->c->ci->target_class->super;
m = mrb_method_search_vm(mrb, &c, mid);
@@ -1306,10 +1313,7 @@ RETRY_TRY_BLOCK:
else {
struct REnv *e = uvenv(mrb, lv-1);
if (!e) {
- mrb_value exc;
- exc = mrb_exc_new_str_lit(mrb, E_NOMETHOD_ERROR, "super called outside of method");
- mrb->exc = mrb_obj_ptr(exc);
- goto L_RAISE;
+ goto out_super;
}
stack = e->stack + 1;
}