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)
This commit is contained in:
Yukihiro "Matz" Matsumoto
2017-04-10 08:21:03 +09:00
parent 47f181519f
commit c063641ab0
+4
View File
@@ -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;
}