]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix registry leak in case of DNS errors
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 30 Sep 2019 11:45:39 +0000 (12:45 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 30 Sep 2019 11:45:39 +0000 (12:45 +0100)
src/libserver/dns.c
src/lua/lua_dns_resolver.c

index 08454c6563b132e539a2de9959a9588ee3dcb811..a6a109b1c24e8f589a886acd810b4c600d6e85fc 100644 (file)
@@ -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;
index 5478ab65ab0809ed6d910b8d2f2aebd7aef2346c..9c57a2c7e6a4bbf14e3e2a2b5f364c24f87268a2 100644 (file)
@@ -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;