]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Fix VM event error handling for finalizers.
authorMike Pall <mike>
Fri, 27 Mar 2026 19:04:50 +0000 (20:04 +0100)
committerMike Pall <mike>
Fri, 27 Mar 2026 19:04:50 +0000 (20:04 +0100)
Reported by Sergey Kaplun. #1445

src/lj_gc.c

index 08972dc52dd2e8bda9780c370a5b10cebc66fe6d..1fed0b54f73e88a19ed01103444c5872d265ccfb 100644 (file)
@@ -525,10 +525,12 @@ static void gc_call_finalizer(global_State *g, lua_State *L,
   if (LJ_HASPROFILE && (oldh & HOOK_PROFILE)) lj_dispatch_update(g);
   g->gc.threshold = oldt;  /* Restore GC threshold. */
   if (errcode) {
+    TValue tmp;
+    copyTV(VL, &tmp, VL->top-1);
+    VL->top--;
     lj_vmevent_send(g, ERRFIN,
-      copyTV(V, V->top++, L->top-1);
+      copyTV(V, V->top++, &tmp);
     );
-    L->top--;
   }
 }