mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-08 15:58:04 +00:00
fix(Core/SpellQueue): Fix undefined behavior when processing SpellQueue. (#21459)
This commit is contained in:
committed by
GitHub
parent
ee69a569c4
commit
91da92f33f
@@ -2377,7 +2377,15 @@ void Player::ProcessSpellQueue()
|
|||||||
if (CanExecutePendingSpellCastRequest(spellInfo))
|
if (CanExecutePendingSpellCastRequest(spellInfo))
|
||||||
{
|
{
|
||||||
ExecuteOrCancelSpellCastRequest(&request);
|
ExecuteOrCancelSpellCastRequest(&request);
|
||||||
SpellQueue.pop_front(); // Remove from the queue
|
|
||||||
|
// ExecuteOrCancelSpellCastRequest() can lead to clearing the SpellQueue.
|
||||||
|
// Example scenario:
|
||||||
|
// Handling a spell → Dealing damage to yourself (e.g., spell_pri_vampiric_touch) →
|
||||||
|
// Killing yourself → Player::setDeathState() → SpellQueue.clear().
|
||||||
|
// Calling std::deque::pop_front() on an empty deque results in undefined behavior,
|
||||||
|
// so an additional check is added.
|
||||||
|
if (!SpellQueue.empty())
|
||||||
|
SpellQueue.pop_front();
|
||||||
}
|
}
|
||||||
else // If the first spell can't execute, stop processing
|
else // If the first spell can't execute, stop processing
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user