LVGL bindings for Rust. A powerful and easy-to-use embedded GUI with many widgets, advanced visual effects (opacity, antialiasing, animations) and low memory requirements (16K RAM, 64K Flash).
MIT License
687
stars
71
forks
source link
Fix strncmp to not blindly read past string end #164
Currently strcmp calls strncmp with usize::MAX which causes a panic due to the use of from_raw_parts.
thread 'main' panicked at library/core/src/panicking.rs:155:5:
unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceed `isize::MAX`
This issue is triggered, for instance, when trying to create a keyboard widget.
This PR changes the implementation of strncmp to iterate over the strings up to the specified size but stopping on null bytes.
Currently
strcmp
callsstrncmp
withusize::MAX
which causes a panic due to the use offrom_raw_parts
.This issue is triggered, for instance, when trying to create a keyboard widget.
This PR changes the implementation of
strncmp
to iterate over the strings up to the specified size but stopping on null bytes.