Core/Groups: Add some checks to prevent a crash with Invites

Core/Groups: Use proper size with SMSG_GROUP_DECLINE Opcode

Fixes issue 4412. (Prevents the crash but the main reason of player being null not solved)

--HG--
branch : trunk
This commit is contained in:
Spp
2010-10-29 14:09:25 +02:00
parent 7b35d0b2e8
commit c9b6f44e9f
2 changed files with 14 additions and 11 deletions
@@ -236,18 +236,18 @@ void WorldSession::HandleGroupDeclineOpcode(WorldPacket & /*recv_data*/)
Group *group = GetPlayer()->GetGroupInvite();
if (!group) return;
// remember leader if online
Player *leader = sObjectMgr.GetPlayer(group->GetLeaderGUID());
// uninvite, group can be deleted
GetPlayer()->UninviteFromGroup();
// remember leader if online
Player *leader = sObjectMgr.GetPlayer(group->GetLeaderGUID());
if (!leader || !leader->GetSession())
return;
// report
WorldPacket data(SMSG_GROUP_DECLINE, 10); // guess size
data << GetPlayer()->GetName();
std::string name = std::string(GetPlayer()->GetName());
WorldPacket data(SMSG_GROUP_DECLINE, name.length());
data << name.c_str();
leader->GetSession()->SendPacket(&data);
}