Detail in 'lua_resetthread'
'lua_resetthread' should reset the CallInfo list before calling 'luaF_close'. luaF_close can call functions, and those functions should not run with dead functions still in the CallInfo list.
This commit is contained in:
9
lstate.c
9
lstate.c
@@ -362,19 +362,18 @@ int lua_resetthread (lua_State *L) {
|
|||||||
CallInfo *ci;
|
CallInfo *ci;
|
||||||
int status;
|
int status;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
ci = &L->base_ci;
|
L->ci = ci = &L->base_ci; /* unwind CallInfo list */
|
||||||
status = luaF_close(L, L->stack, CLOSEPROTECT);
|
|
||||||
setnilvalue(s2v(L->stack)); /* 'function' entry for basic 'ci' */
|
setnilvalue(s2v(L->stack)); /* 'function' entry for basic 'ci' */
|
||||||
|
ci->func = L->stack;
|
||||||
|
ci->callstatus = CIST_C;
|
||||||
|
status = luaF_close(L, L->stack, CLOSEPROTECT);
|
||||||
if (status != CLOSEPROTECT) /* real errors? */
|
if (status != CLOSEPROTECT) /* real errors? */
|
||||||
luaD_seterrorobj(L, status, L->stack + 1);
|
luaD_seterrorobj(L, status, L->stack + 1);
|
||||||
else {
|
else {
|
||||||
status = LUA_OK;
|
status = LUA_OK;
|
||||||
L->top = L->stack + 1;
|
L->top = L->stack + 1;
|
||||||
}
|
}
|
||||||
ci->callstatus = CIST_C;
|
|
||||||
ci->func = L->stack;
|
|
||||||
ci->top = L->top + LUA_MINSTACK;
|
ci->top = L->top + LUA_MINSTACK;
|
||||||
L->ci = ci;
|
|
||||||
L->status = status;
|
L->status = status;
|
||||||
lua_unlock(L);
|
lua_unlock(L);
|
||||||
return status;
|
return status;
|
||||||
|
|||||||
Reference in New Issue
Block a user