summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlokher <lokher@gmail.com>2022-08-25 15:28:25 +0800
committerlokher <lokher@gmail.com>2022-08-25 15:28:25 +0800
commit485e45ea67cff8b823e7dbadba47da75fc3bfc31 (patch)
tree6a061be953a4129b41355d92cdb1fc2d7e853b3e
parent5c61a8b0bcd153b7c393e887794747a5e7821a78 (diff)
Fix host_led_pin_list out of bound issue
-rw-r--r--keyboards/keychron/bluetooth/indicator.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/keyboards/keychron/bluetooth/indicator.c b/keyboards/keychron/bluetooth/indicator.c
index bfe0f5cb17..38e35cceeb 100644
--- a/keyboards/keychron/bluetooth/indicator.c
+++ b/keyboards/keychron/bluetooth/indicator.c
@@ -237,10 +237,16 @@ static void indicator_timer_cb(void *arg) {
}
#ifdef HOST_LED_PIN_LIST
- if (indicator_config.value && (indicator_config.value & 0x80)) {
- writePin(host_led_pin_list[indicator_config.value & 0x0F], HOST_LED_PIN_ON_STATE);
- } else {
- writePin(host_led_pin_list[indicator_config.value & 0x0F], !HOST_LED_PIN_ON_STATE);
+ if (indicator_config.value)
+ {
+ uint8_t idx = (indicator_config.value & 0x0F) - 1;
+ chDbgAssert(idx < HOST_DEVICES_COUNT, "array out of bounds");
+
+ if (indicator_config.value & 0x80) {
+ writePin(host_led_pin_list[idx], HOST_LED_PIN_ON_STATE);
+ } else {
+ writePin(host_led_pin_list[idx], !HOST_LED_PIN_ON_STATE);
+ }
}
#endif