mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 01:08:35 +00:00
fix(Core/Player): SpellQueue avoid possible undefined behavior by copying instead of move (#21444)
This commit is contained in:
@@ -110,11 +110,12 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
|
||||
if (!_player->CanExecutePendingSpellCastRequest(spellInfo))
|
||||
if (_player->CanRequestSpellCast(spellInfo))
|
||||
{
|
||||
recvPacket.rpos(0); // Reset read position to the start of the buffer.
|
||||
WorldPacket packetCopy(recvPacket); // Copy the packet
|
||||
packetCopy.rpos(0); // Reset read position to the start of the buffer.
|
||||
_player->SpellQueue.emplace_back(
|
||||
spellId,
|
||||
spellInfo->GetCategory(),
|
||||
std::move(recvPacket), // Move ownership of recvPacket
|
||||
std::move(packetCopy), // Move ownership of copied packet
|
||||
true // itemCast
|
||||
);
|
||||
return;
|
||||
@@ -424,11 +425,12 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
|
||||
{
|
||||
if (_player->CanRequestSpellCast(spellInfo))
|
||||
{
|
||||
recvPacket.rpos(0); // Reset read position to the start of the buffer.
|
||||
WorldPacket packetCopy(recvPacket); // Copy the packet
|
||||
packetCopy.rpos(0); // Reset read position to the start of the buffer.
|
||||
_player->SpellQueue.emplace_back(
|
||||
spellId,
|
||||
spellInfo->GetCategory(),
|
||||
std::move(recvPacket) // Move ownership of recvPacket
|
||||
std::move(packetCopy) // Move ownership of copied packet
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user