From eda8ab478e63df33fe1fc78d701275716d862258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Fri, 4 Aug 2017 01:54:38 +0200 Subject: [PATCH] Fix memory leaks in auxiliary thread #896 Related also in #935 , #1030 , #1099 --- lib/MySQL_Thread.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index 246340d2e..eec827ad4 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -2544,7 +2544,8 @@ __run_skip_1a: if (mysql_sessions->len > 1) { // take the last element and adjust the map MySQL_Session *mysess_last=(MySQL_Session *)mysql_sessions->index(mysql_sessions->len-1); - sessmap[mysess_last->thread_session_id]=sess_pos; + if (mysess->thread_session_id != mysess_last->thread_session_id) + sessmap[mysess_last->thread_session_id]=sess_pos; } unregister_session(sess_pos); resume_mysql_sessions->add(mysess); @@ -2588,8 +2589,9 @@ __run_skip_1a: sessmap.erase(mysess->thread_session_id); if (mysql_sessions->len > 1) { // take the last element and adjust the map - MySQL_Session *mysess_last=(MySQL_Session *)mysql_sessions->index(mysql_sessions->len-1); - sessmap[mysess_last->thread_session_id]=sess_pos; + MySQL_Session *mysess_last=(MySQL_Session *)mysql_sessions->index(mysql_sessions->len-1); + if (mysess->thread_session_id != mysess_last->thread_session_id) + sessmap[mysess_last->thread_session_id]=sess_pos; } unregister_session(sess_pos); resume_mysql_sessions->add(mysess);