From: Aki Tuomi Date: Mon, 27 Aug 2018 11:16:46 +0000 (+0300) Subject: lib-dns: Always use dns_lookup_free X-Git-Tag: 2.3.4~121 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=041fb1c8b071c72e43a9c67c9771f8c24ab51250;p=thirdparty%2Fdovecot%2Fcore.git lib-dns: Always use dns_lookup_free Ensures that all resources get free'd in single place, Fixes memory leak and event double-unref. Broken in 9ee82e3f660e6e072532283cad8668a578ac137d --- diff --git a/src/lib-dns/dns-lookup.c b/src/lib-dns/dns-lookup.c index 877488c943..31e2365bf3 100644 --- a/src/lib-dns/dns-lookup.c +++ b/src/lib-dns/dns-lookup.c @@ -86,7 +86,6 @@ static void dns_lookup_callback(struct dns_lookup *lookup) lookup->result.msecs); } lookup->callback(&lookup->result, lookup->context); - event_unref(&lookup->event); } static void dns_client_disconnect(struct dns_client *client, const char *error) @@ -207,11 +206,7 @@ int dns_lookup(const char *host, const struct dns_lookup_settings *set, client = dns_client_init(set); client->deinit_client_at_free = TRUE; - if (dns_client_lookup(client, host, callback, context, lookup_r) < 0) { - dns_client_deinit(&client); - return -1; - } - return 0; + return dns_client_lookup(client, host, callback, context, lookup_r); } int dns_lookup_ptr(const struct ip_addr *ip, @@ -223,11 +218,7 @@ int dns_lookup_ptr(const struct ip_addr *ip, client = dns_client_init(set); client->deinit_client_at_free = TRUE; - if (dns_client_lookup_ptr(client, ip, callback, context, lookup_r) < 0) { - dns_client_deinit(&client); - return -1; - } - return 0; + return dns_client_lookup_ptr(client, ip, callback, context, lookup_r); } static void dns_client_idle_timeout(struct dns_client *client) @@ -404,7 +395,7 @@ dns_client_lookup_common(struct dns_client *client, } if (ret <= 0) { dns_lookup_callback(lookup); - pool_unref(&lookup->pool); + dns_lookup_free(&lookup); return -1; } }