From b34100ceec2659e995b0cf2b3e10c6d4790ff18f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Sun, 31 Jul 2022 21:20:27 +0200 Subject: [PATCH] Fix memory leaks for 'username' and 'password' credentials in cluster 'pull' actions --- lib/ProxySQL_Cluster.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/ProxySQL_Cluster.cpp b/lib/ProxySQL_Cluster.cpp index 5ffa8a631..5e1d8bc52 100644 --- a/lib/ProxySQL_Cluster.cpp +++ b/lib/ProxySQL_Cluster.cpp @@ -1249,6 +1249,12 @@ void ProxySQL_Cluster::pull_mysql_users_from_peer(const string& expected_checksu } } } + if (username) { + free(username); + } + if (password) { + free(password); + } __exit_pull_mysql_users_from_peer: if (conn) { if (conn->net.pvio) { @@ -1741,6 +1747,12 @@ void ProxySQL_Cluster::pull_mysql_servers_from_peer(const std::string& checksum, metrics.p_counter_array[p_cluster_counter::pulled_mysql_servers_failure]->Increment(); } } + if (username) { + free(username); + } + if (password) { + free(password); + } __exit_pull_mysql_servers_from_peer: if (conn) { if (conn->net.pvio) { @@ -1913,6 +1925,12 @@ void ProxySQL_Cluster::pull_global_variables_from_peer(const string& var_type, c metrics.p_counter_array[failure_metric]->Increment(); } } + if (username) { + free(username); + } + if (password) { + free(password); + } __exit_pull_mysql_variables_from_peer: if (conn) { if (conn->net.pvio) { @@ -2016,6 +2034,12 @@ void ProxySQL_Cluster::pull_proxysql_servers_from_peer(const std::string& expect metrics.p_counter_array[p_cluster_counter::pulled_proxysql_servers_failure]->Increment(); } } + if (username) { + free(username); + } + if (password) { + free(password); + } __exit_pull_proxysql_servers_from_peer: if (conn) { if (conn->net.pvio) {