Fix host_led_pin_list out of bound issue

This commit is contained in:
lokher 2022-08-25 15:28:25 +08:00
parent 5c61a8b0bc
commit 485e45ea67

View file

@ -237,10 +237,16 @@ static void indicator_timer_cb(void *arg) {
} }
#ifdef HOST_LED_PIN_LIST #ifdef HOST_LED_PIN_LIST
if (indicator_config.value && (indicator_config.value & 0x80)) { if (indicator_config.value)
writePin(host_led_pin_list[indicator_config.value & 0x0F], HOST_LED_PIN_ON_STATE); {
} else { uint8_t idx = (indicator_config.value & 0x0F) - 1;
writePin(host_led_pin_list[indicator_config.value & 0x0F], !HOST_LED_PIN_ON_STATE); 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 #endif