diff --git a/lib/ProxySQL_Admin.cpp b/lib/ProxySQL_Admin.cpp index f80826327..4b3c3b770 100644 --- a/lib/ProxySQL_Admin.cpp +++ b/lib/ProxySQL_Admin.cpp @@ -3761,12 +3761,20 @@ void admin_session_handler(MySQL_Session *sess, void *_pa, PtrSize_t *pkt) { if (query_no_space_length) { // fix bug #925 - while (query_no_space[query_no_space_length-1]==';' || query_no_space[query_no_space_length-1]==' ') { + while (query_no_space_length && + (query_no_space[query_no_space_length-1]==';' || query_no_space[query_no_space_length-1]==' ')) { query_no_space_length--; query_no_space[query_no_space_length]=0; } } + if (query_no_space_length == 0) { + proxy_warning("Empty query\n"); + SPA->send_MySQL_ERR(&sess->client_myds->myprot, (char*)"Empty query"); + run_query = false; + goto __run_query; + } + // add global mutex, see bug #1188 pthread_mutex_lock(&pa->sql_query_global_mutex);