summaryrefslogtreecommitdiff
path: root/sql/rpl_mi.cc
diff options
context:
space:
mode:
authorVicențiu Ciorbaru <vicentiu@mariadb.org>2016-08-16 11:25:11 +0300
committerVicențiu Ciorbaru <vicentiu@mariadb.org>2016-08-23 21:24:36 +0300
commit4eb898bb1663ab470a07e8419de4aa14b5afc667 (patch)
tree81bb1fe2e773e70bfcd4c3500d54333cf7f3ef2d /sql/rpl_mi.cc
parent4da2b83af712492e4c3cb85e0005cde8511fa810 (diff)
downloadmariadb-git-4eb898bb1663ab470a07e8419de4aa14b5afc667.tar.gz
MDEV-10563 Crash during shutdown in Master_info_index::any_slave_sql_running
In well defined C code, the "this" pointer is never NULL. Currently, we were potentially dereferencing a NULL pointer (master_info_index). GCC v6 removes any "if (!this)" conditions as it assumes this is always a non-null pointer. In order to prevent undefined behaviour, check the pointer before dereferencing and remove the check within member functions.
Diffstat (limited to 'sql/rpl_mi.cc')
-rw-r--r--sql/rpl_mi.cc7
1 files changed, 1 insertions, 6 deletions
diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc
index 9c6f4639717..249bf7608e5 100644
--- a/sql/rpl_mi.cc
+++ b/sql/rpl_mi.cc
@@ -1095,8 +1095,6 @@ Master_info_index::get_master_info(LEX_STRING *connection_name,
connection_name->str));
mysql_mutex_assert_owner(&LOCK_active_mi);
- if (!this) // master_info_index is set to NULL on server shutdown
- DBUG_RETURN(NULL);
/* Make name lower case for comparison */
res= strmake(buff, connection_name->str, connection_name->length);
@@ -1250,8 +1248,6 @@ bool Master_info_index::give_error_if_slave_running()
{
DBUG_ENTER("give_error_if_slave_running");
mysql_mutex_assert_owner(&LOCK_active_mi);
- if (!this) // master_info_index is set to NULL on server shutdown
- DBUG_RETURN(TRUE);
for (uint i= 0; i< master_info_hash.records; ++i)
{
@@ -1282,8 +1278,7 @@ uint Master_info_index::any_slave_sql_running()
{
uint count= 0;
DBUG_ENTER("any_slave_sql_running");
- if (!this) // master_info_index is set to NULL on server shutdown
- DBUG_RETURN(count);
+ mysql_mutex_assert_owner(&LOCK_active_mi);
for (uint i= 0; i< master_info_hash.records; ++i)
{