aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_redis.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-11-24 10:05:14 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-11-24 10:05:33 +0000
commitcbc608a75432e9e7f088cdc5ac50ce05d2c0ec7f (patch)
tree95bfd0806a61b16a5fb7514c00ffb8478086ed0b /src/lua/lua_redis.c
parent90237d0d4b0196171226801438b70f8fd3f69686 (diff)
downloadrspamd-cbc608a75432e9e7f088cdc5ac50ce05d2c0ec7f.tar.gz
rspamd-cbc608a75432e9e7f088cdc5ac50ce05d2c0ec7f.zip
[Fix] Fix memory leak for task-less redis requests
Diffstat (limited to 'src/lua/lua_redis.c')
-rw-r--r--src/lua/lua_redis.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/lua/lua_redis.c b/src/lua/lua_redis.c
index 279c58c5b..3566c7e11 100644
--- a/src/lua/lua_redis.c
+++ b/src/lua/lua_redis.c
@@ -600,12 +600,6 @@ rspamd_lua_redis_prepare_connection (lua_State *L, gint *pcbref)
if (rspamd_inet_address_get_port (ip) == 0) {
rspamd_inet_address_set_port (ip, 6379);
}
-
- if (task) {
- rspamd_mempool_add_destructor (task->task_pool,
- (rspamd_mempool_destruct_t)rspamd_inet_address_destroy,
- ip);
- }
}
}
lua_pop (L, 1);
@@ -655,6 +649,10 @@ rspamd_lua_redis_prepare_connection (lua_State *L, gint *pcbref)
rspamd_inet_address_to_string (addr->addr),
rspamd_inet_address_get_port (addr->addr));
+ if (ip) {
+ rspamd_inet_address_destroy (ip);
+ }
+
if (ud->ctx == NULL || ud->ctx->err) {
if (ud->ctx) {
msg_err_task_check ("cannot connect to redis: %s",
@@ -675,6 +673,10 @@ rspamd_lua_redis_prepare_connection (lua_State *L, gint *pcbref)
return ctx;
}
+ if (ip) {
+ rspamd_inet_address_destroy (ip);
+ }
+
return NULL;
}