]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Restore cur_L for specific Lua/C API use case.
authorMike Pall <mike>
Thu, 21 Sep 2023 01:54:08 +0000 (03:54 +0200)
committerMike Pall <mike>
Thu, 21 Sep 2023 01:54:08 +0000 (03:54 +0200)
Thanks to Peter Cawley. #1066

src/lj_err.c

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