diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-06-17 10:36:42 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-06-17 10:36:42 -0300 |
| commit | a304199836ef37af6912a1da6f9b6cad33466a84 (patch) | |
| tree | 0e6a41d43fbe3a6e8eeb8f9985629c667fc28b22 | |
| parent | 6d7cd31feec58011a593cf732274a33dcc1bcb53 (diff) | |
| download | lua-a304199836ef37af6912a1da6f9b6cad33466a84.tar.gz lua-a304199836ef37af6912a1da6f9b6cad33466a84.tar.bz2 lua-a304199836ef37af6912a1da6f9b6cad33466a84.zip | |
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.
| -rw-r--r-- | lstate.c | 9 |
1 files changed, 4 insertions, 5 deletions
| @@ -362,19 +362,18 @@ int lua_resetthread (lua_State *L) { | |||
| 362 | CallInfo *ci; | 362 | CallInfo *ci; |
| 363 | int status; | 363 | int status; |
| 364 | lua_lock(L); | 364 | lua_lock(L); |
| 365 | ci = &L->base_ci; | 365 | L->ci = ci = &L->base_ci; /* unwind CallInfo list */ |
| 366 | status = luaF_close(L, L->stack, CLOSEPROTECT); | ||
| 367 | setnilvalue(s2v(L->stack)); /* 'function' entry for basic 'ci' */ | 366 | setnilvalue(s2v(L->stack)); /* 'function' entry for basic 'ci' */ |
| 367 | ci->func = L->stack; | ||
| 368 | ci->callstatus = CIST_C; | ||
| 369 | status = luaF_close(L, L->stack, CLOSEPROTECT); | ||
| 368 | if (status != CLOSEPROTECT) /* real errors? */ | 370 | if (status != CLOSEPROTECT) /* real errors? */ |
| 369 | luaD_seterrorobj(L, status, L->stack + 1); | 371 | luaD_seterrorobj(L, status, L->stack + 1); |
| 370 | else { | 372 | else { |
| 371 | status = LUA_OK; | 373 | status = LUA_OK; |
| 372 | L->top = L->stack + 1; | 374 | L->top = L->stack + 1; |
| 373 | } | 375 | } |
| 374 | ci->callstatus = CIST_C; | ||
| 375 | ci->func = L->stack; | ||
| 376 | ci->top = L->top + LUA_MINSTACK; | 376 | ci->top = L->top + LUA_MINSTACK; |
| 377 | L->ci = ci; | ||
| 378 | L->status = status; | 377 | L->status = status; |
| 379 | lua_unlock(L); | 378 | lua_unlock(L); |
| 380 | return status; | 379 | return status; |
