Assert that CWallet::SyncMetaData finds oldest transaction. - #11074
Merged
Conversation
This fixes one of the Clang static analyzer warnings mentioned in bitcoin#9573.
promag
reviewed
Aug 17, 2017
| } | ||
| } | ||
|
|
||
| assert(copyFrom); |
Contributor
There was a problem hiding this comment.
From what I've seen there is at least one element in the range:
TxSpends::iterator it = range.first;
const CWalletTx* copyFrom = mapWallet[it->second];
for (; it != range.second; ++i) {
...Maybe this assert should come first:
assert(range.first != range.second);
Contributor
Author
There was a problem hiding this comment.
That would not suffice to silence the analyzer, because copyFrom is also nullptr if the range is nonempty but n == nMinOrderPos in every iteration.
Member
|
utACK 6c4042a |
laanwj
added a commit
that referenced
this pull request
Nov 9, 2017
…ion. 6c4042a Assert that CWallet::SyncMetaData finds oldest transaction. (Eelis) Pull request description: Without this assert, the Clang static analyzer warns about subsequent dereferencing of copyFrom, because it can't be sure that it's not nullptr. See #9573. Tree-SHA512: 83cbcb32c52c94fcfefbc90ec7de2011dacd6bdb0da35adc401b8d8dda6a86de2fa0403e2158592268c2cf15eef4f3d887d98c90f1031d4735d5f4bf9dbc1d23
PastaPastaPasta
pushed a commit
to PastaPastaPasta/dash
that referenced
this pull request
Jan 22, 2020
…ransaction. 6c4042a Assert that CWallet::SyncMetaData finds oldest transaction. (Eelis) Pull request description: Without this assert, the Clang static analyzer warns about subsequent dereferencing of copyFrom, because it can't be sure that it's not nullptr. See bitcoin#9573. Tree-SHA512: 83cbcb32c52c94fcfefbc90ec7de2011dacd6bdb0da35adc401b8d8dda6a86de2fa0403e2158592268c2cf15eef4f3d887d98c90f1031d4735d5f4bf9dbc1d23
deadalnix
pushed a commit
to Bitcoin-ABC/bitcoin-abc
that referenced
this pull request
Mar 5, 2020
…to sync Summary: b0d2ca9 wallet: Exit SyncMetaData if there are no transactions to sync (Wladimir J. van der Laan) Pull request description: Instead of crash with an assertion error, simply exit the function `SyncMetaData` if there is no metadata to sync. Fixes #13110. Tree-SHA512: 44c4789497b5b63963bef66d8b695987dde80764199f6ea0f2c974be19d29c2663f32446a663a2ee9029e143e5d1d9e8a591e52e6e7e795b982782626bec25bb Backport of Core [[bitcoin/bitcoin#13265 | PR13265]] This skips [[bitcoin/bitcoin#11074 | PR11074]] and should avoid the issue found here: bitcoin/bitcoin#13110 Test Plan: ninja check ./bitcoin-qt Reviewers: O1 Bitcoin ABC, #bitcoin_abc, deadalnix Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D5435
ftrader
pushed a commit
to bitcoin-cash-node/bitcoin-cash-node
that referenced
this pull request
May 19, 2020
…to sync Summary: b0d2ca9 wallet: Exit SyncMetaData if there are no transactions to sync (Wladimir J. van der Laan) Pull request description: Instead of crash with an assertion error, simply exit the function `SyncMetaData` if there is no metadata to sync. Fixes #13110. Tree-SHA512: 44c4789497b5b63963bef66d8b695987dde80764199f6ea0f2c974be19d29c2663f32446a663a2ee9029e143e5d1d9e8a591e52e6e7e795b982782626bec25bb Backport of Core [[bitcoin/bitcoin#13265 | PR13265]] This skips [[bitcoin/bitcoin#11074 | PR11074]] and should avoid the issue found here: bitcoin/bitcoin#13110 Test Plan: ninja check ./bitcoin-qt Reviewers: O1 Bitcoin ABC, #bitcoin_abc, deadalnix Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D5435
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Without this assert, the Clang static analyzer warns about subsequent dereferencing of copyFrom, because it can't be sure that it's not nullptr. See #9573.