Skip to content

AP_DAL: add rangefinder null guard#32827

Draft
vlordier wants to merge 1 commit intoArduPilot:masterfrom
vlordier:pr/ap-dal-rangefinder-null-check
Draft

AP_DAL: add rangefinder null guard#32827
vlordier wants to merge 1 commit intoArduPilot:masterfrom
vlordier:pr/ap-dal-rangefinder-null-check

Conversation

@vlordier
Copy link
Copy Markdown

@vlordier vlordier commented Apr 18, 2026

This draft isolates the AP_DAL rangefinder null-guard fix from the larger hardening branch.

Summary:

  • add a narrow null guard in the AP_DAL rangefinder path
  • add focused regression coverage proving missing replay/backend arrays are skipped safely while healthy backends still run

Why:

  • this is a tiny defensive fix and is easier to review separately from the rest of the branch

Validation:

  • branch was split cleanly from upstream/master
  • the branch includes focused regression test source for the missing-backend-array case in this slice
  • not fully validated locally as a standalone branch beyond the split and commit flow
  • draft only pending review

if (_RRNH.num_sensors > 0 && _RRNI == nullptr) {
_RRNI = NEW_NOTHROW log_RRNI[_RRNH.num_sensors];
_backend = NEW_NOTHROW AP_DAL_RangeFinder_Backend *[_RRNH.num_sensors];
_backend = NEW_NOTHROW AP_DAL_RangeFinder_Backend *[_RRNH.num_sensors]{};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this change accomplish?

for (uint8_t i=0; i<_RRNH.num_sensors; i++) {
auto *backend = rangefinder->get_backend(i);
if (backend == nullptr) {
if (backend == nullptr || _backend[i] == nullptr) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any flow path through ArduPilot which can result in _backend[i] being nullptr?

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.

2 participants