diff options
author | daurnimator <quae@daurnimator.com> | 2017-05-22 18:06:40 +1000 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2017-05-22 18:46:30 +1000 |
commit | 91e09ea32148c34965809b8d69987d439d389870 (patch) | |
tree | 216ca00cad9be1eb1f85c2bdca90ad99f1a28c12 /src/lapi.js | |
parent | 6646bebd474b95a2d4cbb8558c0d1cb5b5353de0 (diff) | |
download | fengari-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.js | 3 |
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; |