From cc68f770318be12775ea0b85ab8bd9324753a965 Mon Sep 17 00:00:00 2001 From: MarekZegare4 Date: Tue, 23 Jun 2026 12:05:36 +0200 Subject: [PATCH] fix(companion): null-guard geo-alert picker, clamp loc-share channel idx on load GeoAlertScreen::openPicker() is reachable directly from handleInput()'s Target row, bypassing the _prefs null-check every other path in this screen goes through via activate(). DataStore's loc_share_channel_idx was the only loc_share_* field without a clamp-on-load, unlike its sibling index fields (harmless today since getChannel() bounds-checks it, but inconsistent with the established defensive pattern). Co-Authored-By: Claude Sonnet 4.6 --- examples/companion_radio/DataStore.cpp | 1 + examples/companion_radio/ui-new/GeoAlertScreen.h | 1 + 2 files changed, 2 insertions(+) diff --git a/examples/companion_radio/DataStore.cpp b/examples/companion_radio/DataStore.cpp index 3ccf5f8e..f41011a9 100644 --- a/examples/companion_radio/DataStore.cpp +++ b/examples/companion_radio/DataStore.cpp @@ -372,6 +372,7 @@ void DataStore::loadPrefsInt(const char *filename, NodePrefs& _prefs, double& no rd(&_prefs.loc_share_heartbeat_idx, sizeof(_prefs.loc_share_heartbeat_idx)); if (_prefs.loc_share_enabled > 1) _prefs.loc_share_enabled = 0; if (_prefs.loc_share_target_type > 1) _prefs.loc_share_target_type = 0; + if (_prefs.loc_share_channel_idx >= MAX_GROUP_CHANNELS) _prefs.loc_share_channel_idx = 0; if (_prefs.loc_share_move_idx >= NodePrefs::LOC_SHARE_MOVE_COUNT) _prefs.loc_share_move_idx = 1; if (_prefs.loc_share_interval_idx >= NodePrefs::LOC_SHARE_INTERVAL_COUNT) _prefs.loc_share_interval_idx = 1; if (_prefs.loc_share_heartbeat_idx >= NodePrefs::LOC_SHARE_HEARTBEAT_COUNT) _prefs.loc_share_heartbeat_idx = 0; diff --git a/examples/companion_radio/ui-new/GeoAlertScreen.h b/examples/companion_radio/ui-new/GeoAlertScreen.h index f0446a0b..a82af229 100644 --- a/examples/companion_radio/ui-new/GeoAlertScreen.h +++ b/examples/companion_radio/ui-new/GeoAlertScreen.h @@ -211,6 +211,7 @@ public: } void openPicker() { + if (!_prefs) return; buildTargets(); if (_target_n == 0) { _task->showAlert("No favs / waypoints", 1400); return; } int cur = currentTargetIndex();