Skip to content

Commit 3df8de4

Browse files
Fix out-of-bounds static current_idx when publicServers list shrinks after refresh
Co-authored-by: Longwater1234 <33986524+Longwater1234@users.noreply.github.com>
1 parent 4da03b1 commit 3df8de4

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/WsClient.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ void WsClient::showPublicServerWindow(bool &showPublic)
9090
if (ImGui::Begin("Public Servers", nullptr, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse))
9191
{
9292
static size_t current_idx{0};
93+
if (!publicServers.empty() && current_idx >= publicServers.size())
94+
{
95+
current_idx = 0;
96+
}
9397
if (ImGui::BeginListBox("Select One"))
9498
{
9599
for (size_t i = 0; i < publicServers.size(); ++i)

0 commit comments

Comments
 (0)