From 980cdf835d25e3c391229449d98b672d2794ae91 Mon Sep 17 00:00:00 2001 From: hiker Date: Mon, 16 Nov 2015 18:44:14 +1100 Subject: [PATCH] Avoid crash when clicking on (empty) list while server list is being refreshed. --- src/states_screens/server_selection.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/states_screens/server_selection.cpp b/src/states_screens/server_selection.cpp index d37e5b6fd..80aa361e4 100644 --- a/src/states_screens/server_selection.cpp +++ b/src/states_screens/server_selection.cpp @@ -172,6 +172,10 @@ void ServerSelection::eventCallback( GUIEngine::Widget* widget, else if (name == m_server_list_widget->m_properties[GUIEngine::PROP_ID]) { 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()) + return; const Server *server = ServersManager::get()->getServerBySort(selected_index); uint32_t server_id = server->getServerId();