diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2016-11-25 09:20:47 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2016-11-25 09:20:47 +0900 |
| commit | d77b25410880f0c79bd215c406ec44a9dac07769 (patch) | |
| tree | 5519faefa52478adce9d4b9ae5db892aa9c95912 /src | |
| parent | 6905597f5b750e75e3320a5c9a74e4c270f155eb (diff) | |
| parent | 1ec5994377b45b0299a9c4e6e7ab275792d81bc9 (diff) | |
| download | mruby-d77b25410880f0c79bd215c406ec44a9dac07769.tar.gz mruby-d77b25410880f0c79bd215c406ec44a9dac07769.zip | |
Merge pull request #3287 from bouk/proc-arity
Fix calling .arity on Proc with undefined `initialize`
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); |
