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_http.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_http.c')
-rw-r--r-- | src/lua/lua_http.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/lua/lua_http.c b/src/lua/lua_http.c index a92c1fe8f..68c9bb927 100644 --- a/src/lua/lua_http.c +++ b/src/lua/lua_http.c @@ -441,15 +441,15 @@ lua_http_make_connection (struct lua_http_cbdata *cbd) if (cbd->task) { cbd->conn->log_tag = cbd->task->task_pool->tag.uid; + + if (cbd->item) { + rspamd_symcache_item_async_inc (cbd->task, cbd->item, M); + } } else if (cbd->cfg) { cbd->conn->log_tag = cbd->cfg->cfg_pool->tag.uid; } - if (cbd->item) { - rspamd_symcache_item_async_inc (cbd->task, cbd->item, M); - } - struct rspamd_http_message *msg = cbd->msg; /* Message is now owned by a connection object */ @@ -652,10 +652,13 @@ lua_http_request (lua_State *L) if (lua_type (L, -1) == LUA_TUSERDATA) { task = lua_check_task (L, -1); - ev_base = task->event_loop; - resolver = task->resolver; - session = task->s; - cfg = task->cfg; + + if (task) { + ev_base = task->event_loop; + resolver = task->resolver; + session = task->s; + cfg = task->cfg; + } } lua_pop (L, 1); @@ -823,7 +826,10 @@ lua_http_request (lua_State *L) } else { t = lua_check_text (L, -1); - body = rspamd_fstring_append (body, t->start, t->len); + + if (t) { + body = rspamd_fstring_append(body, t->start, t->len); + } } lua_pop (L, 1); @@ -1043,7 +1049,7 @@ lua_http_request (lua_State *L) cbd->session = session; } - if (rspamd_parse_inet_address (&cbd->addr, + if (msg->host && rspamd_parse_inet_address (&cbd->addr, msg->host->str, msg->host->len, RSPAMD_INET_ADDRESS_PARSE_DEFAULT)) { /* Host is numeric IP, no need to resolve */ gboolean ret; |