fix: Add null check - #7305
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #7305 +/- ##
=========================================
- Coverage 82.1% 82.1% -0.0%
=========================================
Files 1011 1011
Lines 76343 76345 +2
Branches 7417 7412 -5
=========================================
- Hits 62691 62683 -8
- Misses 13652 13662 +10
🚀 New features to boost your workflow:
|
bthomee
approved these changes
May 21, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a defensive null check in iteratePriceData() to avoid dereferencing a null transaction metadata pointer returned by txRead(), improving robustness in the presence of unexpected ledger inconsistencies (e.g., local corruption) without changing behavior on valid data paths.
Changes:
- Add a
nullptrguard afterledger->txRead(prevTx).secondbefore accessingsfAffectedNodes. - Simplify the metadata pointer type declaration by using
std::shared_ptr<STObject const>directly.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mvadari
approved these changes
May 21, 2026
Kassaking7
pushed a commit
to Kassaking7/rippled
that referenced
this pull request
Jun 2, 2026
Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
High Level Overview of Change
Add a missing null check after
txRead()initeratePriceData()(GetAggregatePrice.cpp), preventing a potential nullptr dereference.Context of Change
iteratePriceData()walks the chain of previous transactions that modified a PriceOracle ledger object. At line 72, it callsledger->txRead(prevTx).secondto get the transaction metadata, then immediately dereferences it on the next line(meta->getFieldArray(sfAffectedNodes))without checking for null.This is inconsistent with every other txRead call site in the codebase, which all check for null before dereferencing. If txRead returns a null metadata pointer, this would be a nullptr dereference / crash.
Triggering conditions: The bug cannot be triggered remotely on a node with consistent data. The
sfPreviousTxnIDfield is maintained by the transaction engine and always points to a real transaction. FortxReadto returnnull, the ledger would need to exist but not contain the referenced transaction — which requires pre-existing local data corruption (SHAMap structural corruption, transaction engine bug, or incomplete ledger reconstruction).The fix adds a null guard that returns early, matching the existing defensive pattern used throughout the function.
API Impact
No API impact. This is a defensive null check — behavior is unchanged for nodes with consistent data.
Test Plan
Existing
GetAggregatePrice_testpasses (no behavioral change for valid data paths)Code inspection confirms the fix matches the defensive pattern used at other
txReadcall sites in the codebase