From e5531843ef75b7cd09ebccb46914935207c0e1ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Sun, 13 Nov 2016 20:53:21 +0000 Subject: [PATCH] Fixed 2 memory leaks This should be the root cause of #766 and #796 This patch will be applied to v1.2.x , v1.3.0 and v1.3.1 --- lib/MySQL_HostGroups_Manager.cpp | 1 + lib/MySQL_Monitor.cpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/lib/MySQL_HostGroups_Manager.cpp b/lib/MySQL_HostGroups_Manager.cpp index 0647a449c..fd884731b 100644 --- a/lib/MySQL_HostGroups_Manager.cpp +++ b/lib/MySQL_HostGroups_Manager.cpp @@ -1171,6 +1171,7 @@ void MySQL_HostGroups_Manager::read_only_action(char *hostname, int port, int re // num_rows=resultset->rows_count; // } + delete resultset; if (admindb==NULL) { // we initialize admindb only if needed admindb=new SQLite3DB(); admindb->open((char *)"file:mem_admindb?mode=memory&cache=shared", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX); diff --git a/lib/MySQL_Monitor.cpp b/lib/MySQL_Monitor.cpp index 6d64d7e8c..a6c25c151 100644 --- a/lib/MySQL_Monitor.cpp +++ b/lib/MySQL_Monitor.cpp @@ -1198,6 +1198,13 @@ __end_monitor_ping_loop: } free(buff); } + while (i) { // now free all the addresses/ports + i--; + free(addresses[i]); + free(ports[i]); + } + free(addresses); + free(ports); } __sleep_monitor_ping_loop: