summaryrefslogtreecommitdiff
path: root/src/ldo.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-23 00:05:13 +1000
committerdaurnimator <quae@daurnimator.com>2017-05-23 00:53:05 +1000
commitf7bb8409d6c57b5e9319f4f48d7d02f216b4cc32 (patch)
treeee53a653daa4c049a02c918f7627c8b5aea0518f /src/ldo.js
parentee502076941676ff570866cba36a21bf06c29fc0 (diff)
downloadfengari-f7bb8409d6c57b5e9319f4f48d7d02f216b4cc32.tar.gz
fengari-f7bb8409d6c57b5e9319f4f48d7d02f216b4cc32.tar.bz2
fengari-f7bb8409d6c57b5e9319f4f48d7d02f216b4cc32.zip
src/ldo.js: free CallInfo to recover from (lua) stack overflow
Diffstat (limited to 'src/ldo.js')
-rw-r--r--src/ldo.js4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/ldo.js b/src/ldo.js
index fbef68f..cda1274 100644
--- a/src/ldo.js
+++ b/src/ldo.js
@@ -85,6 +85,10 @@ const luaD_shrinkstack = function(L) {
let goodsize = inuse + Math.floor(inuse / 8) + 2*lstate.EXTRA_STACK;
if (goodsize > luaconf.LUAI_MAXSTACK)
goodsize = luaconf.LUAI_MAXSTACK; /* respect stack limit */
+ if (L.stack.length > luaconf.LUAI_MAXSTACK) /* had been handling stack overflow? */
+ lstate.luaE_freeCI(L); /* free all CIs (list grew because of an error) */
+ /* if thread is currently not handling a stack overflow and its
+ good size is smaller than current size, shrink its stack */
if (inuse <= (luaconf.LUAI_MAXSTACK - lstate.EXTRA_STACK) && goodsize < L.stack.length)
luaD_reallocstack(L, goodsize);
};