fix(airspeed_selector): guard synthetic source in sensor validity check (#27305)

AirspeedSource::SYNTHETIC is declared after SENSOR_3, so its integer value is
4 while _airspeed_validator only has MAX_NUM_AIRSPEED_SENSORS entries, with
valid indices 0..2.

select_airspeed_and_publish() only checked whether _prev_airspeed_src was less
than SENSOR_1 before indexing:

    _airspeed_validator[prev_airspeed_index - 1]

When _prev_airspeed_src is SYNTHETIC, prev_airspeed_index is 4 and this becomes
_airspeed_validator[3], which is out of bounds. Treat sources above SENSOR_3 as
non-sensor sources so only SENSOR_1..SENSOR_3 can index the validator array.
This commit is contained in:
Eurus
2026-05-10 09:47:23 +08:00
committed by GitHub
parent 78abda4e9b
commit 206425da8c
@@ -639,7 +639,7 @@ void AirspeedModule::select_airspeed_and_publish()
bool airspeed_sensor_switching_necessary = false;
const int prev_airspeed_index = static_cast<int>(_prev_airspeed_src);
if (_prev_airspeed_src < AirspeedSource::SENSOR_1) {
if (_prev_airspeed_src < AirspeedSource::SENSOR_1 || _prev_airspeed_src > AirspeedSource::SENSOR_3) {
airspeed_sensor_switching_necessary = true;
} else {