summaryrefslogtreecommitdiffhomepage
path: root/src/vm.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2017-06-14 01:55:05 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2017-06-14 01:55:05 +0900
commit7830b841c74f83c15c4b67ca89f1e908b68e5b7d (patch)
treec6e55fb4083d403ae40b6fa7d27f60ec119d494f /src/vm.c
parentb32ad1307f2e0373e486fa852cbae993c6778bf6 (diff)
downloadmruby-7830b841c74f83c15c4b67ca89f1e908b68e5b7d.tar.gz
mruby-7830b841c74f83c15c4b67ca89f1e908b68e5b7d.zip
Fixed uninitialized local variable bug; ref #3692
Diffstat (limited to 'src/vm.c')
-rw-r--r--src/vm.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/vm.c b/src/vm.c
index 8968d4f65..a0f9adfd4 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -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;