Core/Entities: Fix exploit/crash in inventory-handling (CMSG_OPEN_ITEM) -thanks to leak
(Adds a scrutiny-based check to baghandling: don't allow placing items in bags that are not "usable" as regular bags) --HG-- branch : trunk
This commit is contained in:
@@ -11990,10 +11990,9 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update)
|
||||
if (pItem)
|
||||
{
|
||||
sLog.outDebug("STORAGE: DestroyItem bag = %u, slot = %u, item = %u", bag, slot, pItem->GetEntry());
|
||||
|
||||
// start from destroy contained items (only equipped bag can have its)
|
||||
if (pItem->IsBag() && pItem->IsEquipped()) // this also prevent infinity loop if empty bag stored in bag == slot
|
||||
{
|
||||
// Also remove all contained items if the item is a bag.
|
||||
// This if() prevents item saving crashes if the condition for a bag to be empty before being destroyed was bypassed somehow.
|
||||
if (pItem->IsBag() && !((Bag*)pItem)->IsEmpty()) {
|
||||
for (uint8 i = 0; i < MAX_BAG_SIZE; ++i)
|
||||
DestroyItem(slot, i, update);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user