diff options
author | jackpoz <giacomopoz@gmail.com> | 2014-06-22 19:25:17 +0200 |
---|---|---|
committer | jackpoz <giacomopoz@gmail.com> | 2014-06-22 19:25:17 +0200 |
commit | 4fb56fbfe0f6508c30173422dcb3e6bcc3b381de (patch) | |
tree | 7e1f967d5d9ad106c031c35307fdb8306c5e9000 /src | |
parent | ec8cccffe9638e368def784f6f3d92b133cb7719 (diff) |
Core/Calendar: Fix memory leak in CMSG_CALENDAR_ADD_EVENT handler.
Fix memory leak when malformed CMSG_CALENDAR_ADD_EVENT is received.
This properly fixes the memory leak that 51e38872c72e16bb0f09e660c2660759021b2176 tried to fix, reverted in 927f16de49d6cee6562e2d6bc48714572d142c03.
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Handlers/CalendarHandler.cpp | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/src/server/game/Handlers/CalendarHandler.cpp b/src/server/game/Handlers/CalendarHandler.cpp index 0a797f0e008..dd654fb3ad0 100644 --- a/src/server/game/Handlers/CalendarHandler.cpp +++ b/src/server/game/Handlers/CalendarHandler.cpp @@ -260,26 +260,43 @@ void WorldSession::HandleCalendarAddEvent(WorldPacket& recvData) } else { + // client limits the amount of players to be invited to 100 + const uint32 MaxPlayerInvites = 100; + uint32 inviteCount; - recvData >> inviteCount; + uint64 invitee[MaxPlayerInvites]; + uint8 status[MaxPlayerInvites]; + uint8 rank[MaxPlayerInvites]; + + memset(invitee, 0, sizeof(invitee)); + memset(status, 0, sizeof(status)); + memset(rank, 0, sizeof(rank)); + + try + { + recvData >> inviteCount; + + for (uint32 i = 0; i < inviteCount && i < MaxPlayerInvites; ++i) + { + recvData.readPackGUID(invitee[i]); + recvData >> status[i] >> rank[i]; + } + } + catch (ByteBufferException const&) + { + delete calendarEvent; + calendarEvent = NULL; + throw; + } SQLTransaction trans; if (inviteCount > 1) trans = CharacterDatabase.BeginTransaction(); - // client limits the amount of players to be invited to 100 - const uint32 MaxPlayerInvites = 100; - for (uint32 i = 0; i < inviteCount && i < MaxPlayerInvites; ++i) { - uint64 invitee = 0; - uint8 status = 0; - uint8 rank = 0; - recvData.readPackGUID(invitee); - recvData >> status >> rank; - // 946684800 is 01/01/2000 00:00:00 - default response time - CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), calendarEvent->GetEventId(), invitee, guid, 946684800, CalendarInviteStatus(status), CalendarModerationRank(rank), ""); + CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), calendarEvent->GetEventId(), invitee[i], guid, 946684800, CalendarInviteStatus(status[i]), CalendarModerationRank(rank[i]), ""); sCalendarMgr->AddInvite(calendarEvent, invite, trans); } |