diff options
Diffstat (limited to 'ldo.c')
-rw-r--r-- | ldo.c | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -227,7 +227,7 @@ int luaD_growstack (lua_State *L, int n, int raiseerror) { | |||
227 | luaD_throw(L, LUA_ERRERR); /* error inside message handler */ | 227 | luaD_throw(L, LUA_ERRERR); /* error inside message handler */ |
228 | return 0; /* if not 'raiseerror', just signal it */ | 228 | return 0; /* if not 'raiseerror', just signal it */ |
229 | } | 229 | } |
230 | else { | 230 | else if (n < LUAI_MAXSTACK) { /* avoids arithmetic overflows */ |
231 | int newsize = 2 * size; /* tentative new size */ | 231 | int newsize = 2 * size; /* tentative new size */ |
232 | int needed = cast_int(L->top - L->stack) + n; | 232 | int needed = cast_int(L->top - L->stack) + n; |
233 | if (newsize > LUAI_MAXSTACK) /* cannot cross the limit */ | 233 | if (newsize > LUAI_MAXSTACK) /* cannot cross the limit */ |
@@ -236,14 +236,13 @@ int luaD_growstack (lua_State *L, int n, int raiseerror) { | |||
236 | newsize = needed; | 236 | newsize = needed; |
237 | if (l_likely(newsize <= LUAI_MAXSTACK)) | 237 | if (l_likely(newsize <= LUAI_MAXSTACK)) |
238 | return luaD_reallocstack(L, newsize, raiseerror); | 238 | return luaD_reallocstack(L, newsize, raiseerror); |
239 | else { /* stack overflow */ | ||
240 | /* add extra size to be able to handle the error message */ | ||
241 | luaD_reallocstack(L, ERRORSTACKSIZE, raiseerror); | ||
242 | if (raiseerror) | ||
243 | luaG_runerror(L, "stack overflow"); | ||
244 | return 0; | ||
245 | } | ||
246 | } | 239 | } |
240 | /* else stack overflow */ | ||
241 | /* add extra size to be able to handle the error message */ | ||
242 | luaD_reallocstack(L, ERRORSTACKSIZE, raiseerror); | ||
243 | if (raiseerror) | ||
244 | luaG_runerror(L, "stack overflow"); | ||
245 | return 0; | ||
247 | } | 246 | } |
248 | 247 | ||
249 | 248 | ||