diff --git a/src/states_screens/server_selection.cpp b/src/states_screens/server_selection.cpp index 80aa361e4..4e8841e42 100644 --- a/src/states_screens/server_selection.cpp +++ b/src/states_screens/server_selection.cpp @@ -174,8 +174,12 @@ void ServerSelection::eventCallback( GUIEngine::Widget* widget, int selected_index = m_server_list_widget->getSelectionID(); // This can happen e.g. when the list is empty and the user // clicks somewhere. - if(selected_index >= ServersManager::get()->getNumServers()) + if(selected_index >= ServersManager::get()->getNumServers() || + selected_index<0 ) + { return; + } + const Server *server = ServersManager::get()->getServerBySort(selected_index); uint32_t server_id = server->getServerId();