Revert "Core/Calendar: Fix memory leak when malformed CMSG_CALENDAR_ADD_EVENT is received"

This partially reverts commit 51e38872c7.
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.
This commit is contained in:
jackpoz
2014-06-08 17:18:07 +02:00
parent d2d1b97cff
commit 927f16de49

View File

@@ -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)