smart-leds-rs / ws2812-spi-rs

Use ws2812 on rust with embedded-hal spi
Apache License 2.0
64 stars 23 forks source link

Check for buffer overflow in prerendered variant #29

Closed embediver closed 1 year ago

embediver commented 1 year ago

In the prerendered variant one can pass a iterator with more elements than LEDs, which leads to a buffer overflow.

This PR fixes this by adding a new error type for the prerendered variant.

pub enum Error<E> {
    OutOfBounds,
    Spi(E),
}

Now the current index will be checked in write_byte() and return an OutOfBounds error if it will exceed the data buffer size.

david-sawatzke commented 1 year ago

Thank you, this looks good!