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

This commit is contained in:
practicalswift 2017-08-07 14:28:40 +02:00
parent 6ef3c7ec62
commit 446e2610b0
2 changed files with 3 additions and 5 deletions

View file

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

View file

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