From e04acb377e010968450c6d9824a95911271e7803 Mon Sep 17 00:00:00 2001 From: Madelyn Olson Date: Mon, 6 Jan 2025 14:02:22 -0800 Subject: [PATCH] Fix LUA garbage collector (CVE-2024-46981) (#1513) Reset GC state before closing the lua VM to prevent user data to be wrongly freed while still might be used on destructor callbacks. Created and publish by Redis in their OSS branch. Signed-off-by: Madelyn Olson Co-authored-by: YaacovHazan --- src/eval.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/eval.c b/src/eval.c index e3ffd3f5e..6e9131a6e 100644 --- a/src/eval.c +++ b/src/eval.c @@ -279,6 +279,7 @@ void scriptingRelease(int async) { else dictRelease(lctx.lua_scripts); lctx.lua_scripts_mem = 0; + lua_gc(lctx.lua, LUA_GCCOLLECT, 0); lua_close(lctx.lua); }