Skip to content

fix: assert PeerReservationTable connection is initialized - #7724

Open
BraedonKlock wants to merge 1 commit into
XRPLF:developfrom
BraedonKlock:fix-7509-peer-reservation-table-null-connection
Open

fix: assert PeerReservationTable connection is initialized#7724
BraedonKlock wants to merge 1 commit into
XRPLF:developfrom
BraedonKlock:fix-7509-peer-reservation-table-null-connection

Conversation

@BraedonKlock

Copy link
Copy Markdown

High Level Overview of Change

Adds defensive XRPL_ASSERT checks in PeerReservationTable::insertOrAssign and PeerReservationTable::erase to ensure connection_ has been initialized before it is dereferenced.

Fixes #7509.

Context of Change

PeerReservationTable::connection_ is initialized to nullptr and is set during PeerReservationTable::load(). The normal application startup path calls load() before these methods are reachable, but insertOrAssign() and erase() previously dereferenced connection_ without guarding that initialization invariant.

This change adds explicit assertions before calling connection_->checkoutDb(), making the expected initialization order clear and preventing use-before-initialization from going unchecked.

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)

@ximinez

ximinez commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Hi @BraedonKlock. Thank you for your contributions! We really appreciate them. At this point, we ask that you hold off on submitting any more until we've had a chance to review the current batch. There is a not insignificant engineer overhead for each review, and it may take some time to get caught up. Too many PRs can make that harder. When we've gotten down to 3 open or fewer, feel free to create more!

In the meantime, you can open "Draft" PRs so that changes will be ready to go once we're ready for more. At that time, you'll be able to decide which ones are the best, and convert them to "Ready to review". Keep in mind that you will be responsible for keeping your PRs up to date with develop. The more you open, the more chances you'll have for conflicts, so don't get too carried away. 😄

@BraedonKlock

Copy link
Copy Markdown
Author

Thank you @ximinez for the clarification! I really appreciate the feedback. I completely understand. I'll hold off on opening additional ready for review PRs until my open count is down to three or fewer. In the meantime, I'll continue working locally and use draft PRs if appropriate. Thanks again!

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.

PeerReservationTable null pointer dereference if used before load()

2 participants