diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-09-19 12:08:48 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-09-19 12:08:48 +0100 |
commit | 19424515ec8b3dcb133cef30bf10f8c6b19cc3aa (patch) | |
tree | f38a63933f8164f0a39a60cf04f628d5eef52fcb /src/lua/lua_tcp.c | |
parent | b5a184a0f8b376f3917f103b637a3db17925d2ae (diff) | |
download | rspamd-19424515ec8b3dcb133cef30bf10f8c6b19cc3aa.tar.gz rspamd-19424515ec8b3dcb133cef30bf10f8c6b19cc3aa.zip |
[Minor] Fix some leaks on error paths
Found by: coverity scan
Diffstat (limited to 'src/lua/lua_tcp.c')
-rw-r--r-- | src/lua/lua_tcp.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/lua/lua_tcp.c b/src/lua/lua_tcp.c index 5a34475bc..a1c1f0b20 100644 --- a/src/lua/lua_tcp.c +++ b/src/lua/lua_tcp.c @@ -785,6 +785,7 @@ lua_tcp_write_helper (struct lua_tcp_cbdata *cbd) struct iovec *start; guint niov, i; gint flags = 0; + bool allocated_iov = false; gsize remain; gssize r; struct iovec *cur_iov; @@ -811,6 +812,7 @@ lua_tcp_write_helper (struct lua_tcp_cbdata *cbd) } else { cur_iov = g_malloc0 (niov * sizeof (struct iovec)); + allocated_iov = true; } memcpy (cur_iov, wh->iov, niov * sizeof (struct iovec)); @@ -848,7 +850,7 @@ lua_tcp_write_helper (struct lua_tcp_cbdata *cbd) r = sendmsg (cbd->fd, &msg, flags); } - if (niov >= 1024) { + if (allocated_iov) { g_free (cur_iov); } @@ -1242,7 +1244,7 @@ lua_tcp_register_event (struct lua_tcp_cbdata *cbd) static void lua_tcp_register_watcher (struct lua_tcp_cbdata *cbd) { - if (cbd->item) { + if (cbd->item && cbd->task) { rspamd_symcache_item_async_inc (cbd->task, cbd->item, M); } } @@ -1690,6 +1692,7 @@ lua_tcp_request (lua_State *L) } if (resolver == NULL && cfg == NULL && task == NULL) { + g_free (cbd); return luaL_error (L, "tcp request has bad params: one of " "{resolver,task,config} should be set"); } |