set_led_color accepts led_num equal to num_leds #1

Open
opened 2026-10-30 16:40:38 +01:00 by simon · 0 comments
Owner

ws2812drv_set_led_color() checks led_num > num_leds. For led_num == num_leds the check passes, and set_color() writes one LED past the end of the channel. This LED is the first LED of the next channel.

A negative led_num also passes the check.

Possible fix: use the same check as for channel:

(unsigned int) led_num >= channels[channel].num_leds
`ws2812drv_set_led_color()` checks `led_num > num_leds`. For `led_num == num_leds` the check passes, and `set_color()` writes one LED past the end of the channel. This LED is the first LED of the next channel. A negative `led_num` also passes the check. Possible fix: use the same check as for `channel`: ```c (unsigned int) led_num >= channels[channel].num_leds ```
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
simon/rp2040_ws2812_driver#1
No description provided.