diff options
author | jackpoz <giacomopoz@gmail.com> | 2014-06-08 17:18:07 +0200 |
---|---|---|
committer | jackpoz <giacomopoz@gmail.com> | 2014-06-08 17:18:07 +0200 |
commit | 927f16de49d6cee6562e2d6bc48714572d142c03 (patch) | |
tree | d8b640960d0763d379ba473003af51805f9ed29a /src | |
parent | d2d1b97cffa5384c639f1410e131a75567122281 (diff) |
Revert "Core/Calendar: Fix memory leak when malformed CMSG_CALENDAR_ADD_EVENT is received"
This partially reverts commit 51e38872c72e16bb0f09e660c2660759021b2176.
The stack-initialized variable calendarEvent would have called CalendarMgr::FreeEventId() when it went out of scope, marking the current event id as free and allowing next event to overwrite current event.
This doesn't fix the memory leak issue which still needs to be addressed in a proper way.
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Handlers/CalendarHandler.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/server/game/Handlers/CalendarHandler.cpp b/src/server/game/Handlers/CalendarHandler.cpp index 278c180c380..02cb4f0087f 100644 --- a/src/server/game/Handlers/CalendarHandler.cpp +++ b/src/server/game/Handlers/CalendarHandler.cpp @@ -235,20 +235,20 @@ void WorldSession::HandleCalendarAddEvent(WorldPacket& recvData) recvData.ReadPackedTime(unkPackedTime); recvData >> flags; - CalendarEvent calendarEvent(sCalendarMgr->GetFreeEventId(), guid, 0, CalendarEventType(type), dungeonId, + CalendarEvent* calendarEvent = new CalendarEvent(sCalendarMgr->GetFreeEventId(), guid, 0, CalendarEventType(type), dungeonId, time_t(eventPackedTime), flags, time_t(unkPackedTime), title, description); - if (calendarEvent.IsGuildEvent() || calendarEvent.IsGuildAnnouncement()) + if (calendarEvent->IsGuildEvent() || calendarEvent->IsGuildAnnouncement()) if (Player* creator = ObjectAccessor::FindPlayer(guid)) - calendarEvent.SetGuildId(creator->GetGuildId()); + calendarEvent->SetGuildId(creator->GetGuildId()); - if (calendarEvent.IsGuildAnnouncement()) + if (calendarEvent->IsGuildAnnouncement()) { // 946684800 is 01/01/2000 00:00:00 - default response time - CalendarInvite invite(0, calendarEvent.GetEventId(), 0, guid, 946684800, CALENDAR_STATUS_NOT_SIGNED_UP, CALENDAR_RANK_PLAYER, ""); + CalendarInvite invite(0, calendarEvent->GetEventId(), 0, guid, 946684800, CALENDAR_STATUS_NOT_SIGNED_UP, CALENDAR_RANK_PLAYER, ""); // WARNING: By passing pointer to a local variable, the underlying method(s) must NOT perform any kind // of storage of the pointer as it will lead to memory corruption - sCalendarMgr->AddInvite(&calendarEvent, &invite); + sCalendarMgr->AddInvite(calendarEvent, &invite); } else { @@ -271,15 +271,15 @@ void WorldSession::HandleCalendarAddEvent(WorldPacket& recvData) 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), ""); - sCalendarMgr->AddInvite(&calendarEvent, invite, trans); + CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), calendarEvent->GetEventId(), invitee, guid, 946684800, CalendarInviteStatus(status), CalendarModerationRank(rank), ""); + sCalendarMgr->AddInvite(calendarEvent, invite, trans); } if (inviteCount > 1) CharacterDatabase.CommitTransaction(trans); } - sCalendarMgr->AddEvent(new CalendarEvent(calendarEvent, calendarEvent.GetEventId()), CALENDAR_SENDTYPE_ADD); + sCalendarMgr->AddEvent(calendarEvent, CALENDAR_SENDTYPE_ADD); } void WorldSession::HandleCalendarUpdateEvent(WorldPacket& recvData) |