]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Lua_task: Copy key when setting cache entries to avoid GC race
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 31 Jan 2019 11:39:37 +0000 (11:39 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 31 Jan 2019 11:39:37 +0000 (11:39 +0000)
src/lua/lua_task.c

index 7b21ccc0dca060157138ebdd051d0c2e1c07f5c6..b216eda69e66a13b98a828df6b8793c8b383382b 100644 (file)
@@ -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);