From ddd033f03409d7ab2c04d3f48d09656d19c2f558 Mon Sep 17 00:00:00 2001 From: Neil Horne Date: Sat, 24 Apr 2021 20:59:21 +1000 Subject: [PATCH] Stop Companion crash when conversion source index out of range (#8470) --- companion/src/firmwares/rawsource.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/companion/src/firmwares/rawsource.cpp b/companion/src/firmwares/rawsource.cpp index dfd8ae4d4..eaa651b6c 100644 --- a/companion/src/firmwares/rawsource.cpp +++ b/companion/src/firmwares/rawsource.cpp @@ -351,8 +351,11 @@ RawSource RawSource::convert(RadioDataConversionState & cstate) if (type == SOURCE_TYPE_SWITCH) { QStringList fromSwitchList(getSwitchList(cstate.fromBoard)); QStringList toSwitchList(getSwitchList(cstate.toBoard)); - index = toSwitchList.indexOf(fromSwitchList.at(oldData.id)); // index set to -1 if no match found + if (oldData.id < fromSwitchList.count()) + index = toSwitchList.indexOf(fromSwitchList.at(oldData.id)); + else + index = -1; // perform forced mapping if (index < 0) { if (IS_TARANIS_X7(cstate.toType) && (IS_TARANIS_X9(cstate.fromType) || IS_FAMILY_HORUS_OR_T16(cstate.fromType))) {