From 957b4f8821e7f17c91acd7c149b6ac6390f7207f Mon Sep 17 00:00:00 2001 From: Alex King <89047260+Kinglykrab@users.noreply.github.com> Date: Sat, 9 Mar 2024 19:47:58 -0500 Subject: [PATCH] [Bug Fix] Fix Crash in ClientList::GetCLEIP (#4173) * [Bug Fix] Fix Crash in ClientList::GetCLEIP # Notes - We were not validating pointer when moving to next iterator. # Crashes https://spire.akkadius.com/dev/release/22.46.1?id=19955 https://spire.akkadius.com/dev/release/22.46.1?id=19948 https://spire.akkadius.com/dev/release/22.46.0?id=19945 * Update clientlist.cpp * Update clientlist.cpp --- world/clientlist.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/world/clientlist.cpp b/world/clientlist.cpp index 5936fc1fb..75687eadd 100644 --- a/world/clientlist.cpp +++ b/world/clientlist.cpp @@ -94,12 +94,20 @@ void ClientList::GetCLEIP(uint32 in_ip) { int count = 0; iterator.Reset(); + const auto& zones = Strings::Split(RuleS(World, IPExemptionZones), ","); + while (iterator.MoreElements()) { cle = iterator.GetData(); - - const auto zones = Strings::Split(RuleS(World, IPExemptionZones), ","); - for (const auto &z : zones) { - if (Strings::ToUnsignedInt(z) == cle->zone()) { + + if (!zones.empty() && cle->zone()) { + auto it = std::ranges::find_if( + zones, + [cle](const auto& z) { + return Strings::ToUnsignedInt(z) == cle->zone(); + } + ); + + if (it != zones.end()) { iterator.Advance(); continue; }