Skip to content

fix: Guard against null SLE in NoRippleCheck and GatewayBalances callbacks - #7827

Open
SAY-5 wants to merge 2 commits into
XRPLF:developfrom
SAY-5:ci/null-sle-check-directory-callbacks
Open

fix: Guard against null SLE in NoRippleCheck and GatewayBalances callbacks#7827
SAY-5 wants to merge 2 commits into
XRPLF:developfrom
SAY-5:ci/null-sle-check-directory-callbacks

Conversation

@SAY-5

@SAY-5 SAY-5 commented Jul 18, 2026

Copy link
Copy Markdown

High Level Overview of Change

The forEachItemAfter callback in doNoRippleCheck and the forEachItem callback in doGatewayBalances dereference the SLE argument (ownedItem/sle) without checking for null first. The sibling account handlers (doAccountLines, doAccountChannels, doAccountOffers) all guard their directory callbacks with a if (!sle) { UNREACHABLE(...); return; } block. This adds the same guard to the two handlers that were missing it, so all directory-iteration callbacks are consistent. Fixes #7510.

Context of Change

Both callbacks receive the SLE via view.read() inside the directory helpers. In normal operation read() returns a valid entry, but the other account handlers already treat a null result as an unreachable-but-guarded case rather than dereferencing it. This change closes that inconsistency; the guard uses the existing UNREACHABLE macro with LCOV_EXCL_START/LCOV_EXCL_STOP markers, matching AccountLines.cpp.

API Impact

  • Public API: New feature (new methods and/or new fields)
  • Public API: Breaking change (in general, breaking changes should only impact the next api_version)
  • libxrpl change (any change that may affect libxrpl or dependents of libxrpl)
  • Peer protocol change (must be backward compatible or bump the peer protocol version)

Test Plan

The null-SLE path is defensive and not reachable through the existing RPC unit tests without a corrupted ledger, so it is marked with LCOV_EXCL like the equivalent guard in AccountLines.cpp. The existing NoRippleCheck and GatewayBalances test suites exercise the normal (non-null) path and continue to pass. The change is formatted with the repository .clang-format.

…backs

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
@github-actions

Copy link
Copy Markdown

⚠️ This PR contains unsigned commits. To get your PR merged, please sign them. ⚠️

If only the most recent commit is unsigned, you can run:

  1. Amend the commit: git commit --amend --no-edit -n -S
  2. Overwrite the commit: git push --force-with-lease

If multiple commits are unsigned, you can run:

  1. Go into interactive rebase mode: git rebase --interactive HEAD~<NUM_OF_COMMITS>, where NUM_OF_COMMITS is the number of most recent commits that will be available to edit.
  2. Change "pick" to "edit" for the commits you need to sign, and then save and exit.
  3. For each commit, run: git commit --amend --no-edit -n -S
  4. Continue the rebase: git rebase --continue
  5. Overwrite the commit(s): git push --force-with-lease

If you're new to commit signing, there are different ways to set it up:

Sign commits with gpg

Follow the steps below to set up commit signing with gpg:

  1. Generate a GPG key
  2. Add the GPG key to your GitHub account
  3. Configure git to use your GPG key for commit signing
Sign commits with ssh-agent

Follow the steps below to set up commit signing with ssh-agent:

  1. Generate an SSH key and add it to ssh-agent
  2. Add the SSH key to your GitHub account
  3. Configure git to use your SSH key for commit signing
Sign commits with 1Password

You can also sign commits using 1Password, which lets you sign commits with biometrics without the signing key leaving the local 1Password process.
See use 1Password to sign your commits.

@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

missing null SLE check in directory iteration callbacks

1 participant