From c063641ab0c32ab19715342a4856ed040a1fde14 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Mon, 10 Apr 2017 08:21:03 +0900 Subject: 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) --- src/vm.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') 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(®s[len+2], irep->nlocals-len-2); + } JUMP; } -- cgit v1.2.3