Browse Source

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

0.16
practicalswift 7 years ago
parent
commit
446e2610b0
  1. 6
      src/qt/walletmodeltransaction.cpp
  2. 2
      src/qt/walletmodeltransaction.h

6
src/qt/walletmodeltransaction.cpp

@ -10,7 +10,6 @@ @@ -10,7 +10,6 @@
WalletModelTransaction::WalletModelTransaction(const QList<SendCoinsRecipient> &_recipients) :
recipients(_recipients),
walletTransaction(0),
keyChange(0),
fee(0)
{
walletTransaction = new CWalletTx();
@ -18,7 +17,6 @@ WalletModelTransaction::WalletModelTransaction(const QList<SendCoinsRecipient> & @@ -18,7 +17,6 @@ WalletModelTransaction::WalletModelTransaction(const QList<SendCoinsRecipient> &
WalletModelTransaction::~WalletModelTransaction()
{
delete keyChange;
delete walletTransaction;
}
@ -91,10 +89,10 @@ CAmount WalletModelTransaction::getTotalTransactionAmount() @@ -91,10 +89,10 @@ CAmount WalletModelTransaction::getTotalTransactionAmount()
void WalletModelTransaction::newPossibleKeyChange(CWallet *wallet)
{
keyChange = new CReserveKey(wallet);
keyChange.reset(new CReserveKey(wallet));
}
CReserveKey *WalletModelTransaction::getPossibleKeyChange()
{
return keyChange;
return keyChange.get();
}

2
src/qt/walletmodeltransaction.h

@ -40,7 +40,7 @@ public: @@ -40,7 +40,7 @@ public:
private:
QList<SendCoinsRecipient> recipients;
CWalletTx *walletTransaction;
CReserveKey *keyChange;
std::unique_ptr<CReserveKey> keyChange;
CAmount fee;
};

Loading…
Cancel
Save