[Crash Fix] Raid::UpdateGroupAAs (#4139)

Added checks to potentially resolve a crash situation with raids and group AAs.
This commit is contained in:
Mitch Freeman 2024-03-01 23:46:16 -04:00 committed by GitHub
parent 79c8858ec8
commit 69c42510ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 8 deletions

View File

@ -40,8 +40,6 @@ extern WorldServer worldserver;
Raid::Raid(uint32 raidID)
: GroupIDConsumer(raidID)
{
memset(&raid_aa, 0, sizeof(RaidLeadershipAA_Struct));
memset(group_aa, 0, sizeof(GroupLeadershipAA_Struct) * MAX_RAID_GROUPS);
for (auto& gm : group_mentor) {
gm.mentor_percent = 0;
gm.mentoree = nullptr;
@ -65,8 +63,6 @@ Raid::Raid(uint32 raidID)
Raid::Raid(Client* nLeader)
: GroupIDConsumer()
{
memset(&raid_aa, 0, sizeof(RaidLeadershipAA_Struct));
memset(group_aa, 0, sizeof(GroupLeadershipAA_Struct) * MAX_RAID_GROUPS);
for (auto& gm : group_mentor) {
gm.mentor_percent = 0;
gm.mentoree = nullptr;
@ -451,13 +447,13 @@ void Raid::SaveRaidLeaderAA()
void Raid::UpdateGroupAAs(uint32 gid)
{
if (gid > MAX_RAID_GROUPS) {
if (gid > MAX_RAID_GROUPS || gid == RAID_GROUPLESS || gid < 0) {
return;
}
Client *gl = GetGroupLeader(gid);
if (gl) {
if (gl && gl->IsClient()) {
gl->GetGroupAAs(&group_aa[gid]);
} else {
memset(&group_aa[gid], 0, sizeof(GroupLeadershipAA_Struct));

View File

@ -292,8 +292,8 @@ protected:
bool disbandCheck;
bool forceDisband;
std::string motd;
RaidLeadershipAA_Struct raid_aa;
GroupLeadershipAA_Struct group_aa[MAX_RAID_GROUPS];
RaidLeadershipAA_Struct raid_aa{};
GroupLeadershipAA_Struct group_aa[MAX_RAID_GROUPS]{};
GroupMentor group_mentor[MAX_RAID_GROUPS];