From 9ce70fb3c945e7c10c63d78d18e479a1c11b6211 Mon Sep 17 00:00:00 2001 From: jackpoz Date: Thu, 5 Sep 2013 21:51:02 +0200 Subject: Core/Guild: Fix memory leak on Guild disband Fix memory leak when disbanding a Guild, removed from GuildMgr but never deleted. Due to the different ways of how Guild::Disband() and Guild::DeleteMember() are called, each call to these methods has a different way to delete the Guild if empty/invalid. Valgrind log: 2,127 (240 direct, 1,887 indirect) bytes in 1 blocks are definitely lost in loss record 54 of 81 at operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) by guild_commandscript::HandleGuildCreateCommand(ChatHandler*, char const*) (cs_guild.cpp:91) by ChatHandler::ExecuteCommandInTable(ChatCommand*, char const*, std::string const&) (Chat.cpp:339) by ChatHandler::ExecuteCommandInTable(ChatCommand*, char const*, std::string const&) (Chat.cpp:320) by ChatHandler::ParseCommands(char const*) (Chat.cpp:466) by WorldSession::HandleMessagechatOpcode(WorldPacket&) (ChatHandler.cpp:217) by WorldSession::Update(unsigned int, PacketFilter&) (WorldSession.cpp:317) by World::UpdateSessions(unsigned int) (World.cpp:2632) by World::Update(unsigned int) (World.cpp:1989) by WorldRunnable::run() (WorldRunnable.cpp:60) by ACE_Based::Thread::ThreadTask(void*) (Threading.cpp:186) by ACE_OS_Thread_Adapter::invoke() (in /usr/lib/libACE-6.0.3.so) --- src/server/game/Handlers/CharacterHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/server/game/Handlers/CharacterHandler.cpp') diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index 6a7e6c5dedd..9e1dbc133a5 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -1918,7 +1918,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData) PreparedQueryResult result = CharacterDatabase.Query(stmt); if (result) if (Guild* guild = sGuildMgr->GetGuildById((result->Fetch()[0]).GetUInt32())) - guild->DeleteMember(MAKE_NEW_GUID(lowGuid, 0, HIGHGUID_PLAYER)); + guild->DeleteMember(MAKE_NEW_GUID(lowGuid, 0, HIGHGUID_PLAYER), false, false, true); } if (!HasPermission(RBAC_PERM_TWO_SIDE_ADD_FRIEND)) -- cgit v1.2.3