diff --git a/lib/MySQL_Monitor.cpp b/lib/MySQL_Monitor.cpp index 9c4575d5e..a6fcb3fd7 100644 --- a/lib/MySQL_Monitor.cpp +++ b/lib/MySQL_Monitor.cpp @@ -1492,25 +1492,30 @@ __exit_monitor_replication_lag_thread: int j=-1; num_fields = mysql_num_fields(mmsd->result); fields = mysql_fetch_fields(mmsd->result); - for(k = 0; k < num_fields; k++) { - if (strcmp("Seconds_Behind_Master", fields[k].name)==0) { - j=k; + if (fields) { + for(k = 0; k < num_fields; k++) { + if (strcmp("Seconds_Behind_Master", fields[k].name)==0) { + j=k; + } } - } - if (j>-1) { - MYSQL_ROW row=mysql_fetch_row(mmsd->result); - if (row) { - repl_lag=-1; // this is old behavior + if (j>-1) { + MYSQL_ROW row=mysql_fetch_row(mmsd->result); + if (row) { + repl_lag=-1; // this is old behavior repl_lag=mysql_thread___monitor_slave_lag_when_null; // new behavior, see 669 if (row[j]) { // if Seconds_Behind_Master is not NULL - repl_lag=atoi(row[j]); + repl_lag=atoi(row[j]); + } } } - } - if (repl_lag>=0) { - rc=sqlite3_bind_int64(statement, 5, repl_lag); assert(rc==SQLITE_OK); + if (repl_lag>=0) { + rc=sqlite3_bind_int64(statement, 5, repl_lag); assert(rc==SQLITE_OK); + } else { + rc=sqlite3_bind_null(statement, 5); assert(rc==SQLITE_OK); + } } else { - rc=sqlite3_bind_null(statement, 5); assert(rc==SQLITE_OK); + proxy_error("mysql_fetch_fields returns NULL, please report a bug\n"); + rc=sqlite3_bind_null(statement, 5); assert(rc==SQLITE_OK); } mysql_free_result(mmsd->result); mmsd->result=NULL; diff --git a/lib/MySQL_Protocol.cpp b/lib/MySQL_Protocol.cpp index c414f66a8..1dfc4d812 100644 --- a/lib/MySQL_Protocol.cpp +++ b/lib/MySQL_Protocol.cpp @@ -1713,7 +1713,7 @@ __do_auth: } } else { if (auth_plugin_id == 1) { - if (session_type == PROXYSQL_SESSION_MYSQL || session_type == PROXYSQL_SESSION_SQLITE || PROXYSQL_SESSION_ADMIN || PROXYSQL_SESSION_STATS) { + if (session_type == PROXYSQL_SESSION_MYSQL || session_type == PROXYSQL_SESSION_SQLITE || session_type == PROXYSQL_SESSION_ADMIN || session_type == PROXYSQL_SESSION_STATS) { ret=proxy_scramble_sha1((char *)pass,(*myds)->myconn->scramble_buff,password+1, reply); if (ret) { if (sha1_pass==NULL) { @@ -1726,7 +1726,7 @@ __do_auth: } } } else { // mysql_clear_password - if (session_type == PROXYSQL_SESSION_MYSQL || session_type == PROXYSQL_SESSION_SQLITE || PROXYSQL_SESSION_ADMIN || PROXYSQL_SESSION_STATS) { + if (session_type == PROXYSQL_SESSION_MYSQL || session_type == PROXYSQL_SESSION_SQLITE || session_type == PROXYSQL_SESSION_ADMIN || session_type == PROXYSQL_SESSION_STATS) { /* char sha1_2[SHA_DIGEST_LENGTH+1]; sha1_2[SHA_DIGEST_LENGTH]='\0'; diff --git a/lib/ProxySQL_HTTP_Server.cpp b/lib/ProxySQL_HTTP_Server.cpp index d0f1637da..5b05bf853 100644 --- a/lib/ProxySQL_HTTP_Server.cpp +++ b/lib/ProxySQL_HTTP_Server.cpp @@ -125,7 +125,7 @@ static char *generate_home() { html.append("Uptime = "); { unsigned long long t1=monotonic_time(); - char buf1[30]; + char buf1[50]; unsigned long long uptime = (t1-GloVars.global.start_time)/1000/1000; unsigned long long days = uptime / 86400; unsigned long long hours = (uptime - days*86400)/3600; diff --git a/lib/mysql_connection.cpp b/lib/mysql_connection.cpp index 318ba4a9c..fbdb26296 100644 --- a/lib/mysql_connection.cpp +++ b/lib/mysql_connection.cpp @@ -1641,7 +1641,7 @@ bool MySQL_Connection::MultiplexDisabled() { bool MySQL_Connection::IsKeepMultiplexEnabledVariables(char *query_digest_text) { if (query_digest_text==NULL) return true; - char *query_digest_text_filter_select; + char *query_digest_text_filter_select = NULL; unsigned long query_digest_text_len=strlen(query_digest_text); if (strncasecmp(query_digest_text,"SELECT ",strlen("SELECT "))==0){ query_digest_text_filter_select=(char*)malloc(query_digest_text_len-7+1); diff --git a/lib/mysql_data_stream.cpp b/lib/mysql_data_stream.cpp index 4f3ee0bb1..95c889e48 100644 --- a/lib/mysql_data_stream.cpp +++ b/lib/mysql_data_stream.cpp @@ -871,7 +871,7 @@ int MySQL_Data_Stream::buffer2array() { } if ((queueIN.pkt.size>0) && (queueIN.pkt.size==queueIN.partial) ) { if (myconn->get_status_compression()==true) { - Bytef *dest; + Bytef *dest = NULL; uLongf destLen; proxy_debug(PROXY_DEBUG_PKT_ARRAY, 5, "Copied the whole compressed packet\n"); unsigned int progress=0;