aboutsummaryrefslogtreecommitdiff
path: root/ldo.c
diff options
context:
space:
mode:
Diffstat (limited to 'ldo.c')
-rw-r--r--ldo.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/ldo.c b/ldo.c
index e7e76a65..0ad3120b 100644
--- a/ldo.c
+++ b/ldo.c
@@ -139,9 +139,8 @@ l_noret luaD_throw (lua_State *L, int errcode) {
139 139
140 140
141int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { 141int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) {
142 l_uint32 oldnCcalls = L->nCcalls - L->nci; 142 l_uint32 oldnCcalls = L->nCcalls + L->nci;
143 struct lua_longjmp lj; 143 struct lua_longjmp lj;
144 lua_assert(L->nCcalls >= L->nci);
145 lj.status = LUA_OK; 144 lj.status = LUA_OK;
146 lj.previous = L->errorJmp; /* chain new error handler */ 145 lj.previous = L->errorJmp; /* chain new error handler */
147 L->errorJmp = &lj; 146 L->errorJmp = &lj;
@@ -149,7 +148,7 @@ int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) {
149 (*f)(L, ud); 148 (*f)(L, ud);
150 ); 149 );
151 L->errorJmp = lj.previous; /* restore old error handler */ 150 L->errorJmp = lj.previous; /* restore old error handler */
152 L->nCcalls = oldnCcalls + L->nci; 151 L->nCcalls = oldnCcalls - L->nci;
153 return lj.status; 152 return lj.status;
154} 153}
155 154
@@ -521,7 +520,7 @@ void luaD_call (lua_State *L, StkId func, int nresults) {
521*/ 520*/
522void luaD_callnoyield (lua_State *L, StkId func, int nResults) { 521void luaD_callnoyield (lua_State *L, StkId func, int nResults) {
523 incXCcalls(L); 522 incXCcalls(L);
524 if (getCcalls(L) >= LUAI_MAXCSTACK) /* possible stack overflow? */ 523 if (getCcalls(L) <= CSTACKERR) /* possible stack overflow? */
525 luaE_freeCI(L); 524 luaE_freeCI(L);
526 luaD_call(L, func, nResults); 525 luaD_call(L, func, nResults);
527 decXCcalls(L); 526 decXCcalls(L);
@@ -672,10 +671,10 @@ LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs,
672 else if (L->status != LUA_YIELD) /* ended with errors? */ 671 else if (L->status != LUA_YIELD) /* ended with errors? */
673 return resume_error(L, "cannot resume dead coroutine", nargs); 672 return resume_error(L, "cannot resume dead coroutine", nargs);
674 if (from == NULL) 673 if (from == NULL)
675 L->nCcalls = 1; 674 L->nCcalls = LUAI_MAXCSTACK;
676 else /* correct 'nCcalls' for this thread */ 675 else /* correct 'nCcalls' for this thread */
677 L->nCcalls = getCcalls(from) - from->nci + L->nci + CSTACKCF; 676 L->nCcalls = getCcalls(from) + from->nci - L->nci - CSTACKCF;
678 if (L->nCcalls >= LUAI_MAXCSTACK) 677 if (L->nCcalls <= CSTACKERR)
679 return resume_error(L, "C stack overflow", nargs); 678 return resume_error(L, "C stack overflow", nargs);
680 luai_userstateresume(L, nargs); 679 luai_userstateresume(L, nargs);
681 api_checknelems(L, (L->status == LUA_OK) ? nargs + 1 : nargs); 680 api_checknelems(L, (L->status == LUA_OK) ? nargs + 1 : nargs);