aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-05-05 12:43:38 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-05-05 12:43:38 +0100
commit722a9675c2b2f929b14c047eae0b4b8b5213a06c (patch)
treec07d87c48f8e567208058bfe525c3a79c4e4f82c /src
parent3db7c93cd8cc299420b09d10319eff9a8b572621 (diff)
downloadrspamd-722a9675c2b2f929b14c047eae0b4b8b5213a06c.tar.gz
rspamd-722a9675c2b2f929b14c047eae0b4b8b5213a06c.zip
Remove memory leak in lua_redis.
Diffstat (limited to 'src')
-rw-r--r--src/lua/lua_redis.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/lua/lua_redis.c b/src/lua/lua_redis.c
index 3a1a8e89a..b224c3452 100644
--- a/src/lua/lua_redis.c
+++ b/src/lua/lua_redis.c
@@ -78,25 +78,30 @@ struct lua_redis_userdata {
guint nargs;
};
+static void
+lua_redis_free_args (struct lua_redis_userdata *ud)
+{
+ guint i;
+
+ if (ud->args) {
+ for (i = 0; i < ud->nargs; i ++) {
+ g_free (ud->args[i]);
+ }
+
+ g_free (ud->args);
+ }
+}
static void
lua_redis_fin (void *arg)
{
struct lua_redis_userdata *ud = arg;
- guint i;
if (ud->ctx) {
redisAsyncFree (ud->ctx);
+ lua_redis_free_args (ud);
event_del (&ud->timeout);
luaL_unref (ud->L, LUA_REGISTRYINDEX, ud->cbref);
-
- if (ud->args) {
- for (i = 0; i < ud->nargs; i ++) {
- g_free (ud->args[i]);
- }
-
- g_free (ud->args);
- }
}
}
@@ -211,7 +216,7 @@ lua_redis_callback (redisAsyncContext *c, gpointer r, gpointer priv)
}
}
else {
- lua_redis_push_error ("received no data from server", ud, FALSE);
+ lua_redis_push_error ("received no data from server", ud, TRUE);
}
}
else {
@@ -350,6 +355,7 @@ lua_redis_make_request (lua_State *L)
if (cbref != -1) {
luaL_unref (L, LUA_REGISTRYINDEX, cbref);
}
+
msg_err ("incorrect function invocation");
}
}
@@ -389,6 +395,7 @@ lua_redis_make_request (lua_State *L)
if (ud->ctx == NULL || ud->ctx->err) {
redisAsyncFree (ud->ctx);
+ lua_redis_free_args (ud);
luaL_unref (ud->L, LUA_REGISTRYINDEX, ud->cbref);
lua_pushboolean (L, FALSE);
@@ -414,6 +421,7 @@ lua_redis_make_request (lua_State *L)
}
else {
msg_info ("call to redis failed: %s", ud->ctx->errstr);
+ lua_redis_free_args (ud);
redisAsyncFree (ud->ctx);
luaL_unref (ud->L, LUA_REGISTRYINDEX, ud->cbref);
}