summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lapi.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lapi.js b/src/lapi.js
index c0e619b..1fb8baa 100644
--- a/src/lapi.js
+++ b/src/lapi.js
@@ -91,7 +91,13 @@ const index2addr_ = function(L, idx) {
};
const lua_checkstack = function(L, n) {
- return L.stack.length < luaconf.LUAI_MAXSTACK;
+ let ci = L.ci;
+ let res = L.stack.length < luaconf.LUAI_MAXSTACK;
+
+ if (res && ci.top < L.top + n)
+ ci.top = L.top + n; /* adjust frame top */
+
+ return res;
};
const lua_xmove = function(from, to, n) {