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);
|
SendAuctionExpired(auction, trans);
|
||||||
Global.ScriptMgr.OnAuctionExpire(this, auction);
|
Global.ScriptMgr.OnAuctionExpire(this, auction);
|
||||||
|
|
||||||
|
RemoveAuction(trans, auction);
|
||||||
}
|
}
|
||||||
///- Or perform the transaction
|
///- Or perform the transaction
|
||||||
else
|
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 should send an "item sold" message if the seller is online
|
||||||
//we send the item to the winner
|
//we send the item to the winner
|
||||||
//we send the money to the seller
|
//we send the money to the seller
|
||||||
SendAuctionWon(auction, null, trans);
|
SendAuctionSold(copy, null, trans);
|
||||||
SendAuctionSold(auction, null, trans);
|
SendAuctionWon(copy, null, trans);
|
||||||
Global.ScriptMgr.OnAuctionSuccessful(this, auction);
|
Global.ScriptMgr.OnAuctionSuccessful(this, auction);
|
||||||
}
|
}
|
||||||
|
|
||||||
///- In any case clear the auction
|
|
||||||
RemoveAuction(trans, auction);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run DB changes
|
// Run DB changes
|
||||||
|
|||||||
@@ -390,8 +390,8 @@ namespace Game
|
|||||||
if (canBuyout && placeBid.BidAmount == auction.BuyoutOrUnitPrice)
|
if (canBuyout && placeBid.BidAmount == auction.BuyoutOrUnitPrice)
|
||||||
{
|
{
|
||||||
// buyout
|
// buyout
|
||||||
auctionHouse.SendAuctionWon(auction, player, trans);
|
|
||||||
auctionHouse.SendAuctionSold(auction, null, trans);
|
auctionHouse.SendAuctionSold(auction, null, trans);
|
||||||
|
auctionHouse.SendAuctionWon(auction, player, trans);
|
||||||
|
|
||||||
auctionHouse.RemoveAuction(trans, auction);
|
auctionHouse.RemoveAuction(trans, auction);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user