@@ -1453,6 +1453,8 @@ bool CServerBrowser::OnClick(CGUIElement* pElement)
14531453 for (i = i_b; i != i_e; i++)
14541454 {
14551455 CServerListItem* pServer = *i;
1456+ if (!pServer || !CServerListItem::StaticIsValid (pServer))
1457+ continue ;
14561458
14571459 for (std::size_t j = 0 ; j < pServer->vecPlayers .size (); ++j)
14581460 {
@@ -1748,6 +1750,8 @@ bool CServerBrowser::OnAddressChanged(CGUIElement* pElement)
17481750 for (CServerListIterator i = i_b; i != i_e; i++)
17491751 {
17501752 CServerListItem* pServer = *i;
1753+ if (!pServer || !CServerListItem::StaticIsValid (pServer))
1754+ continue ;
17511755 if (pServer->strHost == strHost && pServer->usGamePort == usPort)
17521756 {
17531757 for (std::size_t iconIndex = 0 ; iconIndex < std::size (m_pAddressFavoriteIcon); ++iconIndex)
@@ -2096,6 +2100,8 @@ bool CServerBrowser::SaveServerList(CXMLNode* pNode, const std::string& strTagNa
20962100 if (iLimit && iProcessed == iLimit)
20972101 break ;
20982102 CServerListItem* pServer = *i;
2103+ if (!pServer || !CServerListItem::StaticIsValid (pServer))
2104+ continue ;
20992105
21002106 // Add the item to the node
21012107 CXMLNode* pSubNode = pNode->CreateSubNode (strTagName.c_str ());
@@ -2442,7 +2448,7 @@ bool CServerBrowser::ProcessServerListRefreshBatch(ServerBrowserType type, size_
24422448 size_t processed = 0 ;
24432449 while (state.iterator != state.endIterator && processed < uiMaxSteps)
24442450 {
2445- CServerListItem* pServer = (state. iterator != state. endIterator ) ? *state.iterator : nullptr ;
2451+ CServerListItem* pServer = *state.iterator ;
24462452
24472453 // The list can briefly hand us null if an item was erased between batches
24482454 if (!pServer)
@@ -2460,16 +2466,17 @@ bool CServerBrowser::ProcessServerListRefreshBatch(ServerBrowserType type, size_
24602466 continue ;
24612467 }
24622468
2469+ // Additional safety check before accessing members
24632470 if (state.bNeedsListClear )
24642471 pServer->iRowIndex = -1 ;
24652472
24662473 if (type == ServerBrowserTypes::FAVOURITES || type == ServerBrowserTypes::RECENTLY_PLAYED)
24672474 {
2468- if (pServer->Address .s_addr != 0 && pServer->usGamePort != 0 )
2475+ if (pServer && pServer ->Address .s_addr != 0 && pServer->usGamePort != 0 )
24692476 GetServerCache ()->GetServerCachedInfo (pServer);
24702477 }
24712478
2472- if (pServer->revisionInList [type] != pServer->uiRevision || state.bClearServerList )
2479+ if (pServer && (pServer ->revisionInList [type] != pServer->uiRevision || state.bClearServerList ) )
24732480 {
24742481 if (!state.bDidUpdateRowIndices )
24752482 {
@@ -2748,6 +2755,8 @@ CServerListItem* CServerBrowser::FindServer(const std::string& strHost, unsigned
27482755 for (CServerListIterator i = i_b; i != i_e; i++)
27492756 {
27502757 CServerListItem* pServer = *i;
2758+ if (!pServer || !CServerListItem::StaticIsValid (pServer))
2759+ continue ;
27512760 if (pServer->strHost == strHost && pServer->usGamePort == usPort)
27522761 return pServer;
27532762 }
@@ -2768,6 +2777,8 @@ unsigned short CServerBrowser::FindServerHttpPort(const std::string& strHost, un
27682777 for (CServerListIterator i = i_b; i != i_e; i++)
27692778 {
27702779 CServerListItem* pServer = *i;
2780+ if (!pServer || !CServerListItem::StaticIsValid (pServer))
2781+ continue ;
27712782 if (pServer->strHost == strHost && pServer->usGamePort == usPort)
27722783 return pServer->m_usHttpPort ;
27732784 }
@@ -2789,6 +2800,8 @@ void CServerBrowser::UpdateRowIndexMembers(ServerBrowserType Type)
27892800 for (int iRowIndex = 0 ; iRowIndex < iRowCount; iRowIndex++)
27902801 {
27912802 CServerListItem* pServer = (CServerListItem*)pServerList->GetItemData (iRowIndex, DATA_PSERVER);
2803+ if (!pServer || !CServerListItem::StaticIsValid (pServer))
2804+ continue ;
27922805 pServer->iRowIndex = iRowIndex;
27932806 }
27942807}
0 commit comments