aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lj_state.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/lj_state.c b/src/lj_state.c
index d7befaff..1a3473b4 100644
--- a/src/lj_state.c
+++ b/src/lj_state.c
@@ -97,8 +97,17 @@ void lj_state_shrinkstack(lua_State *L, MSize used)
97void LJ_FASTCALL lj_state_growstack(lua_State *L, MSize need) 97void LJ_FASTCALL lj_state_growstack(lua_State *L, MSize need)
98{ 98{
99 MSize n; 99 MSize n;
100 if (L->stacksize > LJ_STACK_MAXEX) /* Overflow while handling overflow? */ 100 if (L->stacksize >= LJ_STACK_MAXEX) {
101 lj_err_throw(L, LUA_ERRERR); 101 /* 4. Throw 'error in error handling' when we are _over_ the limit. */
102 if (L->stacksize > LJ_STACK_MAXEX)
103 lj_err_throw(L, LUA_ERRERR); /* Does not invoke an error handler. */
104 /* 1. We are _at_ the limit after the last growth. */
105 if (!L->status) { /* 2. Throw 'stack overflow'. */
106 L->status = LUA_ERRRUN; /* Prevent ending here again for pushed msg. */
107 lj_err_msg(L, LJ_ERR_STKOV); /* May invoke an error handler. */
108 }
109 /* 3. Add space (over the limit) for pushed message and error handler. */
110 }
102 n = L->stacksize + need; 111 n = L->stacksize + need;
103 if (n > LJ_STACK_MAX) { 112 if (n > LJ_STACK_MAX) {
104 n += 2*LUA_MINSTACK; 113 n += 2*LUA_MINSTACK;
@@ -108,8 +117,6 @@ void LJ_FASTCALL lj_state_growstack(lua_State *L, MSize need)
108 n = LJ_STACK_MAX; 117 n = LJ_STACK_MAX;
109 } 118 }
110 resizestack(L, n); 119 resizestack(L, n);
111 if (L->stacksize >= LJ_STACK_MAXEX)
112 lj_err_msg(L, LJ_ERR_STKOV);
113} 120}
114 121
115void LJ_FASTCALL lj_state_growstack1(lua_State *L) 122void LJ_FASTCALL lj_state_growstack1(lua_State *L)