diff options
| author | Francois Chagnon <[email protected]> | 2016-11-14 16:49:45 -0500 |
|---|---|---|
| committer | Bouke van der Bijl <[email protected]> | 2016-11-24 10:23:31 -0500 |
| commit | 1ec5994377b45b0299a9c4e6e7ab275792d81bc9 (patch) | |
| tree | 855977357c0ac152e2246b94ff27c31fbafe1df1 /src | |
| parent | a630c4f413f6af764e68210430e8b61a435d38d7 (diff) | |
| download | mruby-1ec5994377b45b0299a9c4e6e7ab275792d81bc9.tar.gz mruby-1ec5994377b45b0299a9c4e6e7ab275792d81bc9.zip | |
Fix calling .arity on Proc with undefined `initialize`
Reported by @bouk
Diffstat (limited to 'src')
| -rw-r--r-- | src/proc.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/proc.c b/src/proc.c index 1620bddf8..4f770932b 100644 --- a/src/proc.c +++ b/src/proc.c @@ -188,18 +188,13 @@ mrb_proc_call_cfunc(mrb_state *mrb, struct RProc *p, mrb_value self) return (p->body.func)(mrb, self); } -mrb_code* -mrb_proc_iseq(mrb_state *mrb, struct RProc *p) -{ - return p->body.irep->iseq; -} - /* 15.2.17.4.2 */ static mrb_value mrb_proc_arity(mrb_state *mrb, mrb_value self) { struct RProc *p = mrb_proc_ptr(self); - mrb_code *iseq = mrb_proc_iseq(mrb, p); + struct mrb_irep *irep; + mrb_code *iseq; mrb_aspec aspec; int ma, op, ra, pa, arity; @@ -208,6 +203,12 @@ mrb_proc_arity(mrb_state *mrb, mrb_value self) return mrb_fixnum_value(-1); } + irep = p->body.irep; + if (!irep) { + return mrb_fixnum_value(0); + } + + iseq = irep->iseq; /* arity is depend on OP_ENTER */ if (GET_OPCODE(*iseq) != OP_ENTER) { return mrb_fixnum_value(0); |
