@@ -1455,6 +1455,8 @@ bool CServerBrowser::OnClick(CGUIElement* pElement)
14551455 for (i = i_b; i != i_e; i++)
14561456 {
14571457 CServerListItem* pServer = *i;
1458+ if (!pServer || !CServerListItem::StaticIsValid (pServer))
1459+ continue ;
14581460
14591461 for (std::size_t j = 0 ; j < pServer->vecPlayers .size (); ++j)
14601462 {
@@ -1750,6 +1752,8 @@ bool CServerBrowser::OnAddressChanged(CGUIElement* pElement)
17501752 for (CServerListIterator i = i_b; i != i_e; i++)
17511753 {
17521754 CServerListItem* pServer = *i;
1755+ if (!pServer || !CServerListItem::StaticIsValid (pServer))
1756+ continue ;
17531757 if (pServer->strHost == strHost && pServer->usGamePort == usPort)
17541758 {
17551759 for (std::size_t iconIndex = 0 ; iconIndex < std::size (m_pAddressFavoriteIcon); ++iconIndex)
@@ -2098,6 +2102,8 @@ bool CServerBrowser::SaveServerList(CXMLNode* pNode, const std::string& strTagNa
20982102 if (iLimit && iProcessed == iLimit)
20992103 break ;
21002104 CServerListItem* pServer = *i;
2105+ if (!pServer || !CServerListItem::StaticIsValid (pServer))
2106+ continue ;
21012107
21022108 // Add the item to the node
21032109 CXMLNode* pSubNode = pNode->CreateSubNode (strTagName.c_str ());
@@ -2444,7 +2450,7 @@ bool CServerBrowser::ProcessServerListRefreshBatch(ServerBrowserType type, size_
24442450 size_t processed = 0 ;
24452451 while (state.iterator != state.endIterator && processed < uiMaxSteps)
24462452 {
2447- CServerListItem* pServer = (state. iterator != state. endIterator ) ? *state.iterator : nullptr ;
2453+ CServerListItem* pServer = *state.iterator ;
24482454
24492455 // The list can briefly hand us null if an item was erased between batches
24502456 if (!pServer)
@@ -2462,16 +2468,17 @@ bool CServerBrowser::ProcessServerListRefreshBatch(ServerBrowserType type, size_
24622468 continue ;
24632469 }
24642470
2471+ // Additional safety check before accessing members
24652472 if (state.bNeedsListClear )
24662473 pServer->iRowIndex = -1 ;
24672474
24682475 if (type == ServerBrowserTypes::FAVOURITES || type == ServerBrowserTypes::RECENTLY_PLAYED)
24692476 {
2470- if (pServer->Address .s_addr != 0 && pServer->usGamePort != 0 )
2477+ if (pServer && pServer ->Address .s_addr != 0 && pServer->usGamePort != 0 )
24712478 GetServerCache ()->GetServerCachedInfo (pServer);
24722479 }
24732480
2474- if (pServer->revisionInList [type] != pServer->uiRevision || state.bClearServerList )
2481+ if (pServer && (pServer ->revisionInList [type] != pServer->uiRevision || state.bClearServerList ) )
24752482 {
24762483 if (!state.bDidUpdateRowIndices )
24772484 {
@@ -2750,6 +2757,8 @@ CServerListItem* CServerBrowser::FindServer(const std::string& strHost, unsigned
27502757 for (CServerListIterator i = i_b; i != i_e; i++)
27512758 {
27522759 CServerListItem* pServer = *i;
2760+ if (!pServer || !CServerListItem::StaticIsValid (pServer))
2761+ continue ;
27532762 if (pServer->strHost == strHost && pServer->usGamePort == usPort)
27542763 return pServer;
27552764 }
@@ -2770,6 +2779,8 @@ unsigned short CServerBrowser::FindServerHttpPort(const std::string& strHost, un
27702779 for (CServerListIterator i = i_b; i != i_e; i++)
27712780 {
27722781 CServerListItem* pServer = *i;
2782+ if (!pServer || !CServerListItem::StaticIsValid (pServer))
2783+ continue ;
27732784 if (pServer->strHost == strHost && pServer->usGamePort == usPort)
27742785 return pServer->m_usHttpPort ;
27752786 }
@@ -2791,6 +2802,8 @@ void CServerBrowser::UpdateRowIndexMembers(ServerBrowserType Type)
27912802 for (int iRowIndex = 0 ; iRowIndex < iRowCount; iRowIndex++)
27922803 {
27932804 CServerListItem* pServer = (CServerListItem*)pServerList->GetItemData (iRowIndex, DATA_PSERVER);
2805+ if (!pServer || !CServerListItem::StaticIsValid (pServer))
2806+ continue ;
27942807 pServer->iRowIndex = iRowIndex;
27952808 }
27962809}
0 commit comments