diff options
author | Mike Pall <mike> | 2024-03-10 17:13:28 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2024-03-10 17:13:28 +0100 |
commit | 88ed9fdbbba632d174a473a0a97c914089c2916d (patch) | |
tree | 309210f3c33c25064e97bf4e50769fa07f57efb3 | |
parent | defe61a56751a0db5f00ff3ab7b8f45436ba74c8 (diff) | |
download | luajit-88ed9fdbbba632d174a473a0a97c914089c2916d.tar.gz luajit-88ed9fdbbba632d174a473a0a97c914089c2916d.tar.bz2 luajit-88ed9fdbbba632d174a473a0a97c914089c2916d.zip |
Handle stack reallocation in debug.setmetatable() and lua_setmetatable().
Thanks to Sergey Kaplun. #1172
-rw-r--r-- | src/lj_api.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/lj_api.c b/src/lj_api.c index 2018cb8f..d40ade30 100644 --- a/src/lj_api.c +++ b/src/lj_api.c | |||
@@ -975,6 +975,7 @@ LUA_API int lua_setmetatable(lua_State *L, int idx) | |||
975 | /* Flush cache, since traces specialize to basemt. But not during __gc. */ | 975 | /* Flush cache, since traces specialize to basemt. But not during __gc. */ |
976 | if (lj_trace_flushall(L)) | 976 | if (lj_trace_flushall(L)) |
977 | lj_err_caller(L, LJ_ERR_NOGCMM); | 977 | lj_err_caller(L, LJ_ERR_NOGCMM); |
978 | o = index2adr(L, idx); /* Stack may have been reallocated. */ | ||
978 | if (tvisbool(o)) { | 979 | if (tvisbool(o)) { |
979 | /* NOBARRIER: basemt is a GC root. */ | 980 | /* NOBARRIER: basemt is a GC root. */ |
980 | setgcref(basemt_it(g, LJ_TTRUE), obj2gco(mt)); | 981 | setgcref(basemt_it(g, LJ_TTRUE), obj2gco(mt)); |