encoding_rs icon indicating copy to clipboard operation
encoding_rs copied to clipboard

Fix UB from incorrect Vec::set_len usage

Open Nopey opened this issue 6 months ago • 1 comments

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

Nopey avatar Jun 28 '25 05:06 Nopey

force pushed to rephrase two of my safety comments.

Nopey avatar Jul 11 '25 21:07 Nopey