commit c3ca41d: [Minor] Fix task dtor if loaded from a string
Vsevolod Stakhov
vsevolod at highsecure.ru
Tue Aug 13 14:14:04 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-08-13 12:14:06 +0100
URL: https://github.com/rspamd/rspamd/commit/c3ca41d039721004af10cf77083ccebb4b3a0bb8
[Minor] Fix task dtor if loaded from a string
---
src/lua/lua_task.c | 11 ++++-------
1 file 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");
More information about the Commits
mailing list