From 15f5d75e18f6bd0bf876f8b10cc4d1b5b657479c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Fri, 17 Jan 2025 14:02:55 +0100 Subject: [PATCH] Fix memory leak on 'ssl_params' fetch in Monitor --- lib/MySQL_Monitor.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/MySQL_Monitor.cpp b/lib/MySQL_Monitor.cpp index 3caf199e0..e0707c9dc 100644 --- a/lib/MySQL_Monitor.cpp +++ b/lib/MySQL_Monitor.cpp @@ -1546,10 +1546,12 @@ bool MySQL_Monitor_State_Data::set_wait_timeout() { bool MySQL_Monitor_State_Data::create_new_connection() { mysql=mysql_init(NULL); assert(mysql); - MySQLServers_SslParams * ssl_params = NULL; + std::unique_ptr ssl_params { nullptr }; if (use_ssl && port) { - ssl_params = MyHGM->get_Server_SSL_Params(hostname, port, mysql_thread___monitor_username); - MySQL_Connection::set_ssl_params(mysql,ssl_params); + ssl_params = std::unique_ptr( + MyHGM->get_Server_SSL_Params(hostname, port, mysql_thread___monitor_username) + ); + MySQL_Connection::set_ssl_params(mysql, ssl_params.get()); mysql_options(mysql, MARIADB_OPT_SSL_KEYLOG_CALLBACK, (void*)proxysql_keylog_write_line_callback); } unsigned int timeout=mysql_thread___monitor_connect_timeout/1000;