aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-06-17 10:36:42 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-06-17 10:36:42 -0300
commita304199836ef37af6912a1da6f9b6cad33466a84 (patch)
tree0e6a41d43fbe3a6e8eeb8f9985629c667fc28b22
parent6d7cd31feec58011a593cf732274a33dcc1bcb53 (diff)
downloadlua-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.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/lstate.c b/lstate.c
index d2e924d5..4434211a 100644
--- a/lstate.c
+++ b/lstate.c
@@ -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;