summaryrefslogtreecommitdiff
path: root/src/lapi.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-22 18:06:40 +1000
committerdaurnimator <quae@daurnimator.com>2017-05-22 18:46:30 +1000
commit91e09ea32148c34965809b8d69987d439d389870 (patch)
tree216ca00cad9be1eb1f85c2bdca90ad99f1a28c12 /src/lapi.js
parent6646bebd474b95a2d4cbb8558c0d1cb5b5353de0 (diff)
downloadfengari-91e09ea32148c34965809b8d69987d439d389870.tar.gz
fengari-91e09ea32148c34965809b8d69987d439d389870.tar.bz2
fengari-91e09ea32148c34965809b8d69987d439d389870.zip
Compare allowed stack indices to stack_last
Not L.stack.length which is more equivalent to C's L->stacksize
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;