diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-06-14 01:55:05 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-06-14 01:55:05 +0900 |
| commit | 7830b841c74f83c15c4b67ca89f1e908b68e5b7d (patch) | |
| tree | c6e55fb4083d403ae40b6fa7d27f60ec119d494f /src | |
| parent | b32ad1307f2e0373e486fa852cbae993c6778bf6 (diff) | |
| download | mruby-7830b841c74f83c15c4b67ca89f1e908b68e5b7d.tar.gz mruby-7830b841c74f83c15c4b67ca89f1e908b68e5b7d.zip | |
Fixed uninitialized local variable bug; ref #3692
Diffstat (limited to 'src')
| -rw-r--r-- | src/vm.c | 20 |
1 files changed, 9 insertions, 11 deletions
@@ -1241,7 +1241,7 @@ RETRY_TRY_BLOCK: int n = GETARG_C(i); struct RProc *m; struct RClass *c; - mrb_callinfo *ci; + mrb_callinfo *ci = mrb->c->ci; mrb_value recv, result; mrb_sym mid = syms[GETARG_B(i)]; int bidx; @@ -1255,19 +1255,19 @@ RETRY_TRY_BLOCK: bidx = a+n+1; } if (GET_OPCODE(i) != OP_SENDB) { - if (bidx >= mrb->c->ci->nregs) { + if (bidx >= ci->nregs) { stack_extend(mrb, bidx+1); - mrb->c->ci->nregs = bidx+1; + ci->nregs = bidx+1; } SET_NIL_VALUE(regs[bidx]); - SET_NIL_VALUE(blk); + blk = mrb_nil_value(); } else { - mrb_value blk = regs[bidx]; + blk = regs[bidx]; if (!mrb_nil_p(blk) && mrb_type(blk) != MRB_TT_PROC) { - if (bidx >= mrb->c->ci->nregs) { + if (bidx >= ci->nregs) { stack_extend(mrb, bidx+1); - mrb->c->ci->nregs = bidx+1; + ci->nregs = bidx+1; } result = mrb_convert_type(mrb, blk, MRB_TT_PROC, "Proc", "to_proc"); blk = regs[bidx] = result; @@ -1294,10 +1294,8 @@ RETRY_TRY_BLOCK: } mid = missing; if (n != CALL_MAXARGS) { - mrb_value blk = regs[bidx]; - - if (a+2 > irep->nregs) { - stack_extend(mrb, a+2); + if (a+2 >= irep->nregs) { + stack_extend(mrb, a+3); } regs[a+1] = mrb_ary_new_from_values(mrb, n, regs+a+1); regs[a+2] = blk; |
