From 1858ebcefcb7e124297882ddd972b99ad9080f70 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 4 Nov 2019 13:03:57 +1100 Subject: [PATCH] AP_SerialLED: check for valid channel --- libraries/AP_SerialLED/AP_SerialLED.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraries/AP_SerialLED/AP_SerialLED.cpp b/libraries/AP_SerialLED/AP_SerialLED.cpp index 101855755c..03f132dc48 100644 --- a/libraries/AP_SerialLED/AP_SerialLED.cpp +++ b/libraries/AP_SerialLED/AP_SerialLED.cpp @@ -30,7 +30,10 @@ AP_SerialLED::AP_SerialLED() // set number of LEDs per pin bool AP_SerialLED::set_num_LEDs(uint8_t chan, uint8_t num_leds) { - return hal.rcout->set_neopixel_num_LEDs(chan-1, num_leds); + if (chan >= 1 && chan <= 16 && num_leds <= 32) { + return hal.rcout->set_neopixel_num_LEDs(chan-1, num_leds); + } + return false; } // set RGB value on mask of LEDs. chan is PWM output, 1..16