Fix memory leaks in GameEventMgr, MotionMaster, ObjectMgr and Pet#3220
Closed
schell244 wants to merge 1 commit intovmangos:developmentfrom
Closed
Fix memory leaks in GameEventMgr, MotionMaster, ObjectMgr and Pet#3220schell244 wants to merge 1 commit intovmangos:developmentfrom
schell244 wants to merge 1 commit intovmangos:developmentfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR targets leaks and uninitialized state discovered during Valgrind profiling across core systems (events, movement, object/item templates, pets, bots, and some scripts).
Changes:
- Add explicit cleanup paths for dynamically allocated objects (GameEventMgr hardcoded events, MotionMaster generators, ObjectMgr item prototype strings + creature aura arrays, Pet charm info).
- Initialize previously uninitialized members/fields (MasterPlayer mail fields, AV escort AI state).
- Improve error-path cleanup and initialization in bot player spawning (packet broadcaster cleanup, PvP flag initialization).
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/scripts/kalimdor/silithus/temple_of_ahnqiraj/boss_skeram.cpp | Fixes reset-state initialization for boss image pointers. |
| src/scripts/battlegrounds/battleground_alterac.cpp | Initializes AV escort AI state in Reset(). |
| src/game/Spells/SpellAuras.cpp | Adds notes around SpellModifier allocation in dummy aura handling. |
| src/game/PlayerBots/PlayerBotAI.cpp | Adds PvP zone initialization and additional error-path cleanup when spawning bot players. |
| src/game/Objects/Pet.cpp | Clears charm info in Pet destructor to avoid leaks. |
| src/game/Objects/Creature.cpp | Adds a note about potential CreatureGroup lifetime/leak behavior. |
| src/game/ObjectMgr.h | Declares new cleanup helpers for item prototypes and creature auras. |
| src/game/ObjectMgr.cpp | Implements cleanup helpers and calls them on reload/destruction; adds per-entry aura cleanup in LoadCreatureInfo. |
| src/game/Movement/MotionMaster.cpp | Removes stray semicolon; deletes non-static movement generators in ClearType(). |
| src/game/GameEventMgr.h | Makes GameEventMgr destructor non-inline to allow cleanup. |
| src/game/GameEventMgr.cpp | Implements destructor to delete hardcoded event instances. |
| src/game/Chat/MasterPlayer.cpp | Initializes mail-related members in constructor. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
2089
to
2091
| // MEMORY LEAK: SpellModifier created with 'new' but not stored in m_spellmod. | ||
| // On remove, GetSpellMod() may fail to find it, causing a leak. | ||
| if (Player* pPlayer = target->ToPlayer()) |
Comment on lines
+4153
to
4155
| // MEMORY LEAK: CreatureGroup created with 'new' and members added via AddMember(). | ||
| // If creature is destroyed without LeaveCreatureGroup(), member entries leak. | ||
| CreatureGroup* group = leader->GetCreatureGroup(); |
Comment on lines
909
to
914
| MovementGenerator* mg = *it; | ||
| mg->Finalize(*m_owner); | ||
| erase(it); | ||
| if (!isStatic(mg)) | ||
| delete mg; | ||
| it = begin(); |
| { | ||
| sLog.Out(LOG_BASIC, LOG_LVL_ERROR, "PlayerBotAI::SpawnNewPlayer: Unable to add player to map!"); | ||
| newChar->DeletePacketBroadcaster(); | ||
| delete mPlayer; |
Comment on lines
2068
to
2070
| // MEMORY LEAK: SpellModifier created with 'new' but not stored in m_spellmod. | ||
| // On remove, GetSpellMod() may fail to find it, causing a leak. | ||
| if (Player* pPlayer = target->ToPlayer()) |
dc8d6c2 to
6d2b15e
Compare
ratkosrb
referenced
this pull request
Apr 2, 2026
Contributor
|
I've applied the fixes that are actually legit. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🍰 Pullrequest
Fix some memory leaks and uninitialized member variables discovered during Valgrind profiling.
Proof
Issues
How2Test
Todo / Checklist