diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-08-13 12:14:06 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-08-13 12:14:06 +0100 |
commit | c3ca41d039721004af10cf77083ccebb4b3a0bb8 (patch) | |
tree | 02bdc9855f0774c96d4ca28f7992b00f7973020d /src | |
parent | b374f222fe50e1c957e9398b40de9e780f23addf (diff) | |
download | rspamd-c3ca41d039721004af10cf77083ccebb4b3a0bb8.tar.gz rspamd-c3ca41d039721004af10cf77083ccebb4b3a0bb8.zip |
[Minor] Fix task dtor if loaded from a string
Diffstat (limited to 'src')
-rw-r--r-- | src/lua/lua_task.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index f91ce124b..316e91bdd 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -1545,11 +1545,7 @@ lua_task_unmap_dtor (gpointer p) static void lua_task_free_dtor (gpointer p) { - struct rspamd_task *task = (struct rspamd_task *)p; - - if (task->msg.begin) { - g_free ((gpointer)task->msg.begin); - } + g_free (p); } static gint @@ -1600,7 +1596,7 @@ lua_task_load_from_file (lua_State * L) task->msg.begin = data->str; task->msg.len = data->len; rspamd_mempool_add_destructor (task->task_pool, - lua_task_free_dtor, task); + lua_task_free_dtor, data->str); res = TRUE; g_string_free (data, FALSE); /* Buffer is still valid */ } @@ -1667,7 +1663,8 @@ lua_task_load_from_string (lua_State * L) task = rspamd_task_new (NULL, cfg, NULL, NULL, NULL); task->msg.begin = g_strdup (str_message); task->msg.len = message_len; - rspamd_mempool_add_destructor (task->task_pool, lua_task_free_dtor, task); + rspamd_mempool_add_destructor (task->task_pool, lua_task_free_dtor, + (gpointer)task->msg.begin); } else { return luaL_error (L, "invalid arguments"); |