From 7f567048d2145bdeda889194ca30d8830e43293a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Sun, 19 Nov 2017 19:03:26 +0100 Subject: [PATCH] Fixed few anomalies detected with valgrind --- lib/MySQL_Thread.cpp | 4 ++-- lib/mysql_connection.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index dee779834..1dbdae64c 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -1977,9 +1977,9 @@ void MySQL_Threads_Handler::init(unsigned int num, size_t stack) { } int rc=pthread_attr_setstacksize(&attr, stacksize); assert(rc==0); - mysql_threads=(proxysql_mysql_thread_t *)malloc(sizeof(proxysql_mysql_thread_t)*num_threads); + mysql_threads=(proxysql_mysql_thread_t *)calloc(num_threads,sizeof(proxysql_mysql_thread_t)); #ifdef IDLE_THREADS - mysql_threads_idles=(proxysql_mysql_thread_t *)malloc(sizeof(proxysql_mysql_thread_t)*num_threads); + mysql_threads_idles=(proxysql_mysql_thread_t *)calloc(num_threads,sizeof(proxysql_mysql_thread_t)); #endif // IDLE_THREADS } diff --git a/lib/mysql_connection.cpp b/lib/mysql_connection.cpp index f455c5a99..db51b43a4 100644 --- a/lib/mysql_connection.cpp +++ b/lib/mysql_connection.cpp @@ -196,6 +196,9 @@ MySQL_Connection::~MySQL_Connection() { delete userinfo; userinfo=NULL; } + if (local_stmts) { + delete local_stmts; + } if (mysql) { // always decrease the counter if (ret_mysql) @@ -207,9 +210,6 @@ MySQL_Connection::~MySQL_Connection() { if (MyRS) { delete MyRS; } - if (local_stmts) { - delete local_stmts; - } if (query.stmt) { query.stmt=NULL; }