Avoid crash (index could be -1).

This commit is contained in:
hiker 2015-11-28 12:32:00 +11:00
parent 09a32c2132
commit e2a6d1c33c

View File

@ -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();