mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-23 14:47:44 +08:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user