From: Vsevolod Stakhov Date: Mon, 30 Sep 2019 11:45:39 +0000 (+0100) Subject: [Fix] Fix registry leak in case of DNS errors X-Git-Tag: 2.0~95 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1b39b28f6796c2a849af88a0cddb62210c9d7307;p=rspamd.git [Fix] Fix registry leak in case of DNS errors --- diff --git a/src/libserver/dns.c b/src/libserver/dns.c index 08454c656..a6a109b1c 100644 --- a/src/libserver/dns.c +++ b/src/libserver/dns.c @@ -208,6 +208,8 @@ make_dns_request_task_common (struct rspamd_task *task, if (!forced && task->dns_requests >= task->cfg->dns_max_requests) { msg_info_task ("stop resolving on reaching %ud requests", task->dns_requests); + + return FALSE; } return TRUE; diff --git a/src/lua/lua_dns_resolver.c b/src/lua/lua_dns_resolver.c index 5478ab65a..9c57a2c7e 100644 --- a/src/lua/lua_dns_resolver.c +++ b/src/lua/lua_dns_resolver.c @@ -486,7 +486,11 @@ lua_dns_resolver_resolve_common (lua_State *L, lua_pushboolean (L, TRUE); } else { - lua_pushnil (L); + if (item) { + rspamd_symcache_item_async_dec_check (task, item, M); + } + + goto err; } if (item) { @@ -506,6 +510,11 @@ err: g_free (cbdata->user_str); } + /* Callback is not called in this case */ + if (cbdata->cbref != -1) { + luaL_unref (L, LUA_REGISTRYINDEX, cbdata->cbref); + } + lua_pushnil (L); return 1;