diff options
Diffstat (limited to 'ldo.c')
-rw-r--r-- | ldo.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -139,7 +139,8 @@ l_noret luaD_throw (lua_State *L, int errcode) { | |||
139 | 139 | ||
140 | 140 | ||
141 | int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { | 141 | int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { |
142 | l_uint32 oldnCcalls = L->nCcalls + L->nci; | 142 | global_State *g = G(L); |
143 | l_uint32 oldnCcalls = g->Cstacklimit - (L->nCcalls + L->nci); | ||
143 | struct lua_longjmp lj; | 144 | struct lua_longjmp lj; |
144 | lj.status = LUA_OK; | 145 | lj.status = LUA_OK; |
145 | lj.previous = L->errorJmp; /* chain new error handler */ | 146 | lj.previous = L->errorJmp; /* chain new error handler */ |
@@ -148,7 +149,7 @@ int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { | |||
148 | (*f)(L, ud); | 149 | (*f)(L, ud); |
149 | ); | 150 | ); |
150 | L->errorJmp = lj.previous; /* restore old error handler */ | 151 | L->errorJmp = lj.previous; /* restore old error handler */ |
151 | L->nCcalls = oldnCcalls - L->nci; | 152 | L->nCcalls = g->Cstacklimit - oldnCcalls - L->nci; |
152 | return lj.status; | 153 | return lj.status; |
153 | } | 154 | } |
154 | 155 | ||
@@ -671,7 +672,7 @@ LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs, | |||
671 | else if (L->status != LUA_YIELD) /* ended with errors? */ | 672 | else if (L->status != LUA_YIELD) /* ended with errors? */ |
672 | return resume_error(L, "cannot resume dead coroutine", nargs); | 673 | return resume_error(L, "cannot resume dead coroutine", nargs); |
673 | if (from == NULL) | 674 | if (from == NULL) |
674 | L->nCcalls = LUAI_MAXCSTACK; | 675 | L->nCcalls = CSTACKTHREAD; |
675 | else /* correct 'nCcalls' for this thread */ | 676 | else /* correct 'nCcalls' for this thread */ |
676 | L->nCcalls = getCcalls(from) + from->nci - L->nci - CSTACKCF; | 677 | L->nCcalls = getCcalls(from) + from->nci - L->nci - CSTACKCF; |
677 | if (L->nCcalls <= CSTACKERR) | 678 | if (L->nCcalls <= CSTACKERR) |