encoding_rs
encoding_rs copied to clipboard
Fix UB from incorrect Vec::set_len usage
The clippy::uninit_vec lint pointed out this issue in a few places, and then some manual review found many more places where Vec::set_len was being abused.
This introduces buffer zeroing in several places, which will have a performance impact. In order to safely avoid this zeroing, we will need to support &mut [MaybeUninit<u8>] as an output buffer.
For more information, see the clippy lint's documentation: https://rust-lang.github.io/rust-clippy/master/index.html#uninit_vec
force pushed to rephrase two of my safety comments.