]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Handle stack reallocation in debug.setmetatable() and lua_setmetatable().
authorMike Pall <mike>
Sun, 10 Mar 2024 16:13:28 +0000 (17:13 +0100)
committerMike Pall <mike>
Sun, 10 Mar 2024 16:13:28 +0000 (17:13 +0100)
Thanks to Sergey Kaplun. #1172

src/lj_api.c

index 2018cb8fa89d7c2b18cda8d4ac8c0678504fc812..d40ade30cc585bb4681783681d31ffd24aabf75b 100644 (file)
@@ -975,6 +975,7 @@ LUA_API int lua_setmetatable(lua_State *L, int idx)
     /* Flush cache, since traces specialize to basemt. But not during __gc. */
     if (lj_trace_flushall(L))
       lj_err_caller(L, LJ_ERR_NOGCMM);
+    o = index2adr(L, idx);  /* Stack may have been reallocated. */
     if (tvisbool(o)) {
       /* NOBARRIER: basemt is a GC root. */
       setgcref(basemt_it(g, LJ_TTRUE), obj2gco(mt));