mirror of
https://github.com/redis/redis.git
synced 2026-04-21 03:01:35 -04:00
Fix LUA garbage collector (CVE-2024-46981)
Reset GC state before closing the lua VM to prevent user data to be wrongly freed while still might be used on destructor callbacks.
This commit is contained in:
@@ -266,6 +266,7 @@ void freeLuaScriptsSync(dict *lua_scripts, list *lua_scripts_lru_list, lua_State
|
||||
unsigned int lua_tcache = (unsigned int)(uintptr_t)ud;
|
||||
#endif
|
||||
|
||||
lua_gc(lua, LUA_GCCOLLECT, 0);
|
||||
lua_close(lua);
|
||||
|
||||
#if defined(USE_JEMALLOC)
|
||||
|
||||
@@ -198,6 +198,7 @@ static void luaEngineFreeCtx(void *engine_ctx) {
|
||||
unsigned int lua_tcache = (unsigned int)(uintptr_t)ud;
|
||||
#endif
|
||||
|
||||
lua_gc(lua_engine_ctx->lua, LUA_GCCOLLECT, 0);
|
||||
lua_close(lua_engine_ctx->lua);
|
||||
zfree(lua_engine_ctx);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user