From 350f17e46c2b08e5bc27c185a4416ab51e4ffc86 Mon Sep 17 00:00:00 2001 From: cosmoer Date: Mon, 30 Aug 2021 23:49:11 +0800 Subject: [PATCH] Bug#104725: Memory leak when set host_cache_size to 0 without using --skip-host-cache Signed-off-by: cosmoer --- sql/hostname.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sql/hostname.cc b/sql/hostname.cc index 1889eb03223..af6f69c1a48 100644 --- a/sql/hostname.cc +++ b/sql/hostname.cc @@ -280,6 +280,7 @@ static void add_hostname_impl(const char *ip_key, const char *hostname, static void add_hostname(const char *ip_key, const char *hostname, bool validated, Host_errors *errors) { + uint size; if (specialflag & SPECIAL_NO_HOST_CACHE) return; @@ -287,7 +288,11 @@ static void add_hostname(const char *ip_key, const char *hostname, mysql_mutex_lock(&hostname_cache->lock); - add_hostname_impl(ip_key, hostname, validated, errors, now); + size= hostname_cache_size(); + if (size > 0) + { + add_hostname_impl(ip_key, hostname, validated, errors, now); + } mysql_mutex_unlock(&hostname_cache->lock); -- 2.32.0.windows.2