Core/AuctionHouse: Fixed possible use after free when auctions are removed with offline buyers
Port From (https://github.com/TrinityCore/TrinityCore/commit/1f73cf9f19679f5b888f9df475b94c9405f2d746)
This commit is contained in:
@@ -785,20 +785,25 @@ namespace Game
|
||||
{
|
||||
SendAuctionExpired(auction, trans);
|
||||
Global.ScriptMgr.OnAuctionExpire(this, auction);
|
||||
|
||||
RemoveAuction(trans, auction);
|
||||
}
|
||||
///- Or perform the transaction
|
||||
else
|
||||
{
|
||||
// Copy data before freeing AuctionPosting in auctionHouse->RemoveAuction
|
||||
// Because auctionHouse->SendAuctionWon can unload items if bidder is offline
|
||||
// we need to RemoveAuction before sending mails
|
||||
AuctionPosting copy = auction;
|
||||
RemoveAuction(trans, auction);
|
||||
|
||||
//we should send an "item sold" message if the seller is online
|
||||
//we send the item to the winner
|
||||
//we send the money to the seller
|
||||
SendAuctionWon(auction, null, trans);
|
||||
SendAuctionSold(auction, null, trans);
|
||||
SendAuctionSold(copy, null, trans);
|
||||
SendAuctionWon(copy, null, trans);
|
||||
Global.ScriptMgr.OnAuctionSuccessful(this, auction);
|
||||
}
|
||||
|
||||
///- In any case clear the auction
|
||||
RemoveAuction(trans, auction);
|
||||
}
|
||||
|
||||
// Run DB changes
|
||||
|
||||
@@ -390,8 +390,8 @@ namespace Game
|
||||
if (canBuyout && placeBid.BidAmount == auction.BuyoutOrUnitPrice)
|
||||
{
|
||||
// buyout
|
||||
auctionHouse.SendAuctionWon(auction, player, trans);
|
||||
auctionHouse.SendAuctionSold(auction, null, trans);
|
||||
auctionHouse.SendAuctionWon(auction, player, trans);
|
||||
|
||||
auctionHouse.RemoveAuction(trans, auction);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user