From 4cdbd2af61262cdbef6a9035fe90611e4b2e9200 Mon Sep 17 00:00:00 2001 From: Valentin Rakush Date: Thu, 7 Nov 2019 20:51:53 +0000 Subject: [PATCH] Fix mem leak in HGMCU thread --- lib/MySQL_HostGroups_Manager.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/MySQL_HostGroups_Manager.cpp b/lib/MySQL_HostGroups_Manager.cpp index a53b83968..8ce2e2e5a 100644 --- a/lib/MySQL_HostGroups_Manager.cpp +++ b/lib/MySQL_HostGroups_Manager.cpp @@ -640,12 +640,16 @@ static void * HGCU_thread_run() { myconn = (MySQL_Connection *)MyHGM->queue.remove(); if (myconn==NULL) { // intentionally exit immediately + delete conn_array; return NULL; } conn_array->add(myconn); while (MyHGM->queue.size()) { myconn=(MySQL_Connection *)MyHGM->queue.remove(); - if (myconn==NULL) return NULL; + if (myconn==NULL) { + delete conn_array; + return NULL; + } conn_array->add(myconn); } unsigned int l=conn_array->len; @@ -738,6 +742,7 @@ static void * HGCU_thread_run() { free(errs); free(ret); } + delete conn_array; }