Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged

Conversation

practicalswift
Copy link
Contributor

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

@sipa
Copy link
Member

sipa commented Jul 24, 2017

Is it possible to change this to use a unique_ptr instead?

@promag
Copy link
Member

promag commented Jul 24, 2017

👍 @sipa suggestion.

Correct me if I'm wrong, but from what I've seen, WalletModelTransaction::keyChange pointer is initialized to null, and only has a value when newPossibleKeyChange is called. So, in the first call, this would delete NULL.

Moreover, in the ~WalletModelTransaction it also delete keyChange which can be null if newPossibleKeyChange is not called.

@practicalswift
Copy link
Contributor Author

@sipa Sure, I'll fix!

@promag We're doing delete NULL all over the codebase assuming it is a no-op :-)

@promag
Copy link
Member

promag commented Jul 25, 2017

Yeah it's safe, can be avoided though.

@luke-jr
Copy link
Member

luke-jr commented Jul 26, 2017

But there's no reason to avoid it..

@practicalswift practicalswift force-pushed the fix-newPossibleKeyChange-memory-leak branch 2 times, most recently from 4b7a29e to 1ce39c5 Compare August 7, 2017 12:29
@practicalswift
Copy link
Contributor Author

Now using unique_ptr. Please review :-)

@practicalswift practicalswift force-pushed the fix-newPossibleKeyChange-memory-leak branch from 1ce39c5 to 446e261 Compare August 7, 2017 14:42
@jonasschnelli
Copy link
Contributor

utACK 1ce39c59c22a5878b5af6a4ff821db83c988e8b7

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 446e261. FWIW #10244 (commit "Remove most direct bitcoin calls from qt/walletmodel.cpp") takes this cleanup further, combining key and transaction into a pending transaction object and referencing that through a unique pointer.

@maflcko maflcko added the GUI label Sep 25, 2017
@promag
Copy link
Member

promag commented Oct 8, 2017

utACK 446e261.

@laanwj
Copy link
Member

laanwj commented Nov 17, 2017

utACK 446e261

@laanwj laanwj merged commit 446e261 into bitcoin:master Nov 17, 2017
laanwj added a commit that referenced this pull request Nov 17, 2017
…CWallet *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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 17, 2020
…(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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 22, 2020
…(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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 22, 2020
…(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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 29, 2020
…(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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 29, 2020
…(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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 29, 2020
…(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
@practicalswift practicalswift deleted the fix-newPossibleKeyChange-memory-leak branch April 10, 2021 19:32
gades pushed a commit to cosanta/cosanta-core that referenced this pull request Mar 8, 2022
…(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
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants