summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2017-04-10 08:21:03 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2017-04-10 08:25:44 +0900
commitc063641ab0c32ab19715342a4856ed040a1fde14 (patch)
tree4473a7a95eddc90137185b50fd0d8c5911d20347
parent47f181519f009e91aac06b0f8a6f529f6dfcf579 (diff)
downloadmruby-c063641ab0c32ab19715342a4856ed040a1fde14.tar.gz
mruby-c063641ab0c32ab19715342a4856ed040a1fde14.zip
Clear local (but non-argument) variables in OP_ENTER.
Otherwise, the following script prints an uninitialized value. def f(*a) if false b = 15 end p b end f(1,2,3)
-rw-r--r--src/vm.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/vm.c b/src/vm.c
index 0fba22c2c..49f10c5a5 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -1637,6 +1637,10 @@ RETRY_TRY_BLOCK:
}
pc += o + 1;
}
+ /* clear local (but non-argument) variables */
+ if (irep->nlocals-len-2 > 0) {
+ stack_clear(&regs[len+2], irep->nlocals-len-2);
+ }
JUMP;
}