resize_channel moves the wrong memory range #2

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

resize_channel() moves the buffers of the upper channels with memmove(), but it uses source = c->fb[i]. This is the start of the resized channel. The upper channels start at c->fb[i] + c->num_leds.

The result is correct only when c->num_leds is 0. This is the case when each channel gets its size once, in ascending order (as in fw_control_board/src/framebuffer.c). A second resize of a channel moves the wrong range and corrupts the buffers of the upper channels.

Possible fix:

ws2812_led *source = c->fb[i] + c->num_leds;
ws2812_led *target = source + size_diff;
`resize_channel()` moves the buffers of the upper channels with `memmove()`, but it uses `source = c->fb[i]`. This is the start of the resized channel. The upper channels start at `c->fb[i] + c->num_leds`. The result is correct only when `c->num_leds` is 0. This is the case when each channel gets its size once, in ascending order (as in `fw_control_board/src/framebuffer.c`). A second resize of a channel moves the wrong range and corrupts the buffers of the upper channels. Possible fix: ```c ws2812_led *source = c->fb[i] + c->num_leds; ws2812_led *target = source + size_diff; ```
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#2
No description provided.