Skip to content

Commit

Permalink
Merge bitcoin#10920: [qt] Fix potential memory leak in newPossibleKey…
Browse files Browse the repository at this point in the history
…(ChangeCWallet *wallet)

446e261 [qt] Fix potential memory leak in newPossibleKey(ChangeCWallet *wallet) (practicalswift)

Pull request description:

  Fix potential memory leak in `newPossibleKey(ChangeCWallet *wallet)`.

Tree-SHA512: 252d3828133a0d241cc649aed1280e14a5d5ea47b7b2989039cfa5061a8e35183c7f36d7320aa0ac1b4dcab31e584b358dbbb2fe645a412371d0a460878e2b58
  • Loading branch information
laanwj authored and PastaPastaPasta committed Jan 29, 2020
1 parent 4433160 commit 581c49d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions src/qt/walletmodeltransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@
WalletModelTransaction::WalletModelTransaction(const QList<SendCoinsRecipient> &_recipients) :
recipients(_recipients),
walletTransaction(0),
keyChange(0),
fee(0)
{
walletTransaction = new CWalletTx();
}

WalletModelTransaction::~WalletModelTransaction()
{
delete keyChange;
delete walletTransaction;
}

Expand Down Expand Up @@ -97,10 +95,10 @@ CAmount WalletModelTransaction::getTotalTransactionAmount() const

void WalletModelTransaction::newPossibleKeyChange(CWallet *wallet)
{
keyChange = new CReserveKey(wallet);
keyChange.reset(new CReserveKey(wallet));
}

CReserveKey *WalletModelTransaction::getPossibleKeyChange()
{
return keyChange;
return keyChange.get();
}
2 changes: 1 addition & 1 deletion src/qt/walletmodeltransaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class WalletModelTransaction
private:
QList<SendCoinsRecipient> recipients;
CWalletTx *walletTransaction;
CReserveKey *keyChange;
std::unique_ptr<CReserveKey> keyChange;
CAmount fee;
};

Expand Down

0 comments on commit 581c49d

Please sign in to comment.