From 4d148e5c0c624eb5630ed18c4842dc7f4efcf45f Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Thu, 21 Sep 2023 11:25:46 +0200 Subject: [PATCH] fix(radio): Use SWRC_NONE if switch cannot be found (#4005) --- radio/src/storage/yaml/yaml_datastructs_funcs.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/radio/src/storage/yaml/yaml_datastructs_funcs.cpp b/radio/src/storage/yaml/yaml_datastructs_funcs.cpp index 92b5a9fae07..ea5bc9b6b23 100644 --- a/radio/src/storage/yaml/yaml_datastructs_funcs.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_funcs.cpp @@ -845,6 +845,7 @@ static uint32_t r_swtchSrc(const YamlNode* node, const char* val, uint8_t val_le && val[3] >= '0' && val[3] <= '2') { ival = switchLookupIdx(val, val_len - 1) * 3; + if (ival < 0) return SWSRC_NONE; ival += yaml_str2int(val + 3, val_len - 2); ival += SWSRC_FIRST_SWITCH; @@ -853,6 +854,7 @@ static uint32_t r_swtchSrc(const YamlNode* node, const char* val, uint8_t val_le && val[2] >= '0' && val[2] <= '2') { ival = switchLookupIdx(val, val_len - 1) * 3; + if (ival < 0) return SWSRC_NONE; ival += yaml_str2int(val + 2, val_len - 2); ival += SWSRC_FIRST_SWITCH;