Description
encoding_rs currently has UB in the form of creating uninitialized u8's via set_len
Here are 2 examples where the UB is crystal clear:
Lines 2007 to 2010 in dd9d99b
Lines 2044 to 2047 in dd9d99b
set_len is also used in 7 functions in lib.rs, but I haven't looked at them very closely.
The docs for set_len explicitly say https://doc.rust-lang.org/std/vec/struct.Vec.html#method.set_len :
The elements at old_len..new_len must be initialized.
Some relevant discussion can be found here rust-lang/unsafe-code-guidelines#71
rustc itself has a lint specifically for this kind of thing: rust-lang/rust#75968
Using MaybeUninit::uninit().assume_init() is instant UB unless the target type is itself composed entirely of MaybeUninit
My understanding is this is currently considered UB, but this rule may be relaxed in the future to allow types where all bit patterns are valid to store uninitalized if they are not read from.