aboutsummaryrefslogtreecommitdiff
path: root/src/lj_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_api.c')
-rw-r--r--src/lj_api.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lj_api.c b/src/lj_api.c
index 386bcada..d4048d79 100644
--- a/src/lj_api.c
+++ b/src/lj_api.c
@@ -104,7 +104,12 @@ LUA_API int lua_checkstack(lua_State *L, int size)
104 if (size > LUAI_MAXCSTACK || (L->top - L->base + size) > LUAI_MAXCSTACK) { 104 if (size > LUAI_MAXCSTACK || (L->top - L->base + size) > LUAI_MAXCSTACK) {
105 return 0; /* Stack overflow. */ 105 return 0; /* Stack overflow. */
106 } else if (size > 0) { 106 } else if (size > 0) {
107 lj_state_checkstack(L, (MSize)size); 107 int avail = (int)(mref(L->maxstack, TValue) - L->top);
108 if (size > avail &&
109 lj_state_cpgrowstack(L, (MSize)(size - avail)) != LUA_OK) {
110 L->top--;
111 return 0; /* Out of memory. */
112 }
108 } 113 }
109 return 1; 114 return 1;
110} 115}