From b0030d4cd663ba83261ffb3965f31c64d27b8778 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 31 Jan 2019 11:39:37 +0000 Subject: [PATCH] [Minor] Lua_task: Copy key when setting cache entries to avoid GC race --- src/lua/lua_task.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index 7b21ccc0dc..b216eda69e 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -1216,7 +1216,8 @@ lua_task_set_cached (lua_State *L, struct rspamd_task *task, const gchar *key, } else { entry = rspamd_mempool_alloc (task->task_pool, sizeof (*entry)); - g_hash_table_insert (task->lua_cache, (void *)key, entry); + g_hash_table_insert (task->lua_cache, + rspamd_mempool_strdup (task->task_pool, key), entry); } entry->ref = luaL_ref (L, LUA_REGISTRYINDEX); -- 2.47.3