aboutsummaryrefslogtreecommitdiff
path: root/src/lapi.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/lapi.js')
-rw-r--r--src/lapi.js3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/lapi.js b/src/lapi.js
index 79c666c..ca5a8a0 100644
--- a/src/lapi.js
+++ b/src/lapi.js
@@ -94,7 +94,7 @@ const lua_checkstack = function(L, n) {
let res;
let ci = L.ci;
assert(n >= 0, "negative 'n'");
- if (L.stack.length - L.top > n) /* stack large enough? */
+ if (L.stack_last - L.top > n) /* stack large enough? */
res = true;
else { /* no; need to grow stack */
let inuse = L.top + lstate.EXTRA_STACK;
@@ -152,6 +152,7 @@ const lua_pushvalue = function(L, idx) {
const lua_settop = function(L, idx) {
let func = L.ci.funcOff;
if (idx >= 0) {
+ assert(idx <= L.stack_last - (func + 1), "new top too large");
while (L.top < func + 1 + idx)
L.stack[L.top++] = new TValue(CT.LUA_TNIL, null);
L.top = func + 1 + idx;