From 890888f3e3e87be75ebc1ea65b23232fe57511b9 Mon Sep 17 00:00:00 2001 From: Neil Horne Date: Sat, 24 Apr 2021 19:47:50 +1000 Subject: [PATCH] Stop Companion crash when conversion switch index out of range (#8469) --- companion/src/firmwares/rawswitch.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/companion/src/firmwares/rawswitch.cpp b/companion/src/firmwares/rawswitch.cpp index 7aef46922..f609e7942 100644 --- a/companion/src/firmwares/rawswitch.cpp +++ b/companion/src/firmwares/rawswitch.cpp @@ -191,7 +191,10 @@ RawSwitch RawSwitch::convert(RadioDataConversionState & cstate) QStringList fromSwitchList(getSwitchList(cstate.fromBoard)); QStringList toSwitchList(getSwitchList(cstate.toBoard)); // set to -1 if no match found - newIdx = toSwitchList.indexOf(fromSwitchList.at(swtch.quot)); + if (swtch.quot < fromSwitchList.count()) + newIdx = toSwitchList.indexOf(fromSwitchList.at(swtch.quot)); + else + newIdx = -1; // perform forced mapping if (newIdx < 0) { if (IS_TARANIS_X7(cstate.toType) && (IS_TARANIS_X9(cstate.fromType) || IS_FAMILY_HORUS_OR_T16(cstate.fromType))) {