-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
test: Check for some unlikely null dereferences in tests #5004
Open
ximinez
wants to merge
29
commits into
XRPLF:develop
Choose a base branch
from
ximinez:pr/test_fixes
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
95ca921
test: Check for some unlikely null dereferences in tests
ximinez 7ae906c
Merge remote-tracking branch 'upstream/develop' into pr/test_fixes
ximinez 540713d
Merge remote-tracking branch 'upstream/develop' into pr/test_fixes
ximinez a926a2d
Merge remote-tracking branch 'upstream/develop' into pr/test_fixes
ximinez d5dd37b
Merge commit 'c706926' into pr/test_fixes
ximinez 546cd42
Merge commit 'f6879da' into pr/test_fixes
ximinez 16835cf
Move CMake directory
0ff9758
Rearrange sources
b52276e
Rewrite includes
501f1f8
Recompute loops
fb8b17e
Merge remote-tracking branch 'upstream/develop' into pr/test_fixes
ximinez 85beb42
Fix formatting
ximinez a173ecc
Merge remote-tracking branch 'upstream/develop' into pr/test_fixes
ximinez 38344ba
Merge remote-tracking branch 'upstream/develop' into pr/test_fixes
ximinez 1c9d1bb
Merge remote-tracking branch 'upstream/develop' into pr/test_fixes
ximinez 045e50f
Merge remote-tracking branch 'upstream/develop' into pr/test_fixes
ximinez d51702d
[FOLD] Review feedback from @ckeshava:
ximinez 0c867c9
Merge remote-tracking branch 'upstream/develop' into pr/test_fixes
ximinez 828c444
Merge remote-tracking branch 'upstream/develop' into pr/test_fixes
ximinez 46ecfe2
Merge remote-tracking branch 'upstream/develop' into pr/test_fixes
ximinez 5508609
Merge remote-tracking branch 'upstream/develop' into pr/test_fixes
ximinez 9a8cb65
Merge remote-tracking branch 'upstream/develop' into pr/test_fixes
ximinez 24aad0a
Merge remote-tracking branch 'upstream/develop' into pr/test_fixes
ximinez 2c00a3e
Merge remote-tracking branch 'upstream/develop' into pr/test_fixes
ximinez ef96f58
Merge remote-tracking branch 'upstream/develop' into pr/test_fixes
ximinez 54dfbb3
Merge remote-tracking branch 'upstream/develop' into pr/test_fixes
ximinez 4098f94
Merge remote-tracking branch 'upstream/develop' into pr/test_fixes
ximinez d83ad93
Merge remote-tracking branch 'upstream/develop' into pr/test_fixes
ximinez 2c57792
Merge remote-tracking branch 'upstream/develop' into pr/test_fixes
ximinez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,7 +51,9 @@ void | |
nflags::operator()(Env& env) const | ||
{ | ||
auto const sle = env.le(account_); | ||
if (sle->isFieldPresent(sfFlags)) | ||
if (!sle) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before line 44 (above), for the sake of consistency, we need to introduce a similar check There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. Fixed. |
||
env.test.fail(); | ||
else if (sle->isFieldPresent(sfFlags)) | ||
env.test.expect((sle->getFieldU32(sfFlags) & mask_) == 0); | ||
else | ||
env.test.pass(); | ||
|
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The data members
flags::account_
andnflags::account_
always hold a valid instance of theAccount
class. These data members are not pointers orstd::optional
values.Hence,
env.le(account_)
must always exist, isn't it? Are you envisioning a future modification to theseflags
andnflags
classes, due to which a null pointer might be returned here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A valid instance of an
Account
does not guarantee that that account has been created / funded on the ledger. So even though theAccount
is valid, a nullsle
could easily be returned. Consider this test:That's a perfectly validly written test, but without this change, it'll dereference a null
SLE
and crash. With this change, the test will fail in the changed functions, but it won't crash.