From cdb1bbddfd2b48570950df9b70629f6bf6be7379 Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Thu, 26 Mar 2020 07:04:32 +0100 Subject: [PATCH] Menu: Fix a crash when we've got no entries or are out of bounds --- src/menu-fn/m_internetgames.cpp | 1 - src/menu-fn/w_listbox.cpp | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/menu-fn/m_internetgames.cpp b/src/menu-fn/m_internetgames.cpp index 06caff0f..698e188f 100644 --- a/src/menu-fn/m_internetgames.cpp +++ b/src/menu-fn/m_internetgames.cpp @@ -133,7 +133,6 @@ void inet_lb_changed(int val) inet_lbServers_Map.SetScroll(val); inet_lbServers_Game.SetScroll(val); inet_lbServers_Players.SetScroll(val); - inet_lbServers_Addresses.SetScroll(val); } void menu_internetgames_init(void) diff --git a/src/menu-fn/w_listbox.cpp b/src/menu-fn/w_listbox.cpp index 04cae4b4..2c9e667c 100644 --- a/src/menu-fn/w_listbox.cpp +++ b/src/menu-fn/w_listbox.cpp @@ -119,7 +119,9 @@ void CListBox::SetSize(int w, int h) void CListBox::SetScroll(int i) { - m_scroll = i; + if (i >= 0 && i < LB_MAX_ENTRIES) { + m_scroll = i; + } } void CListBox::SetChanged(void(int val) func)