diff --git a/libraries/AP_CANManager/AP_MAVLinkCAN.cpp b/libraries/AP_CANManager/AP_MAVLinkCAN.cpp index 12dfd5879db..ecf1cdb60fe 100644 --- a/libraries/AP_CANManager/AP_MAVLinkCAN.cpp +++ b/libraries/AP_CANManager/AP_MAVLinkCAN.cpp @@ -207,7 +207,7 @@ void AP_MAVLinkCAN::_handle_can_filter_modify(const mavlink_message_t &msg) mavlink_can_filter_modify_t p; mavlink_msg_can_filter_modify_decode(&msg, &p); const int8_t bus = int8_t(p.bus)-1; - if (bus >= HAL_NUM_CAN_IFACES || hal.can[bus] == nullptr) { + if (bus < 0 || bus >= HAL_NUM_CAN_IFACES || hal.can[bus] == nullptr) { return; } if (p.num_ids > ARRAY_SIZE(p.ids)) {