Restore cur_L for specific Lua/C API use case.

Thanks to Peter Cawley. #1066
This commit is contained in:
Mike Pall 2023-09-21 03:54:08 +02:00
parent b8919781d4
commit e86990f7f2

View File

@ -174,12 +174,15 @@ static void *err_unwind(lua_State *L, void *stopcf, int errcode)
case FRAME_PCALL: /* FF pcall() frame. */ case FRAME_PCALL: /* FF pcall() frame. */
case FRAME_PCALLH: /* FF pcall() frame inside hook. */ case FRAME_PCALLH: /* FF pcall() frame inside hook. */
if (errcode) { if (errcode) {
global_State *g;
if (errcode == LUA_YIELD) { if (errcode == LUA_YIELD) {
frame = frame_prevd(frame); frame = frame_prevd(frame);
break; break;
} }
g = G(L);
setgcref(g->cur_L, obj2gco(L));
if (frame_typep(frame) == FRAME_PCALL) if (frame_typep(frame) == FRAME_PCALL)
hook_leave(G(L)); hook_leave(g);
L->base = frame_prevd(frame) + 1; L->base = frame_prevd(frame) + 1;
L->cframe = cf; L->cframe = cf;
unwindstack(L, L->base); unwindstack(L, L->base);