]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Gracefully handle broken custom allocator.
authorMike Pall <mike>
Thu, 16 Oct 2025 11:23:51 +0000 (13:23 +0200)
committerMike Pall <mike>
Thu, 16 Oct 2025 11:23:51 +0000 (13:23 +0200)
Reported by Alex Orlenko. #1393

src/lj_state.c

index 3cad8cc1840d77c01fc3a3f62ef810353e5f6610..fb6d41a5f9bcb61cf8849dda48370fd25e5f2c0a 100644 (file)
@@ -261,7 +261,11 @@ LUA_API lua_State *lua_newstate(lua_Alloc allocf, void *allocd)
   }
 #endif
   GG = (GG_State *)allocf(allocd, NULL, 0, sizeof(GG_State));
-  if (GG == NULL || !checkptrGC(GG)) return NULL;
+  if (GG == NULL) return NULL;
+  if (!checkptrGC(GG)) {
+    allocf(allocd, GG, sizeof(GG_State), 0);
+    return NULL;
+  }
   memset(GG, 0, sizeof(GG_State));
   L = &GG->L;
   g = &GG->g;