From 459a3f12c272541454cd6abffb13dd87ccc5bc09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Tue, 27 Jul 2021 14:41:25 +0200 Subject: [PATCH] Added nullity checks for params for 'lag_action_set_server_status' --- lib/MySQL_HostGroups_Manager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/MySQL_HostGroups_Manager.cpp b/lib/MySQL_HostGroups_Manager.cpp index adfeb840a..b0ca4dc45 100644 --- a/lib/MySQL_HostGroups_Manager.cpp +++ b/lib/MySQL_HostGroups_Manager.cpp @@ -3375,7 +3375,9 @@ __exit_replication_lag_action: /** * @brief Finds the supplied server in the provided 'MyHGC' and sets the status * either to 'MYSQL_SERVER_STATUS_SHUNNED_REPLICATION_LAG' if 'enable' is - * 'false' or 'MYSQL_SERVER_STATUS_ONLINE' if 'true'. + * 'false' or 'MYSQL_SERVER_STATUS_ONLINE' if 'true'. If either of the + * 'myhgc' or 'address' params are 'NULL' the function performs no action, + * and returns immediately. * * @param myhgc The MySQL Hostgroup Container in which to perform the server * search. @@ -3385,6 +3387,8 @@ __exit_replication_lag_action: * @param enable Boolean specifying if the server should be enabled or not. */ void lag_action_set_server_status(MyHGC* myhgc, char* address, int port, int lag_count, bool enable) { + if (myhgc == NULL || address == NULL) return; + for (int j=0; j<(int)myhgc->mysrvs->cnt(); j++) { MySrvC *mysrvc=(MySrvC *)myhgc->mysrvs->servers->index(j); if (strcmp(mysrvc->address,address)==0 && mysrvc->port==port) {