fix(Core/Player): SpellQueue avoid possible undefined behavior by copying instead of move (#21444)
This commit is contained in:
parent
3854d00dee
commit
75441ddb3b
1 changed files with 6 additions and 4 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue