Closed
Description
A weird Borrow
implementation that returns a different result for each call can create a string with uninitialized bytes with join() implementation of [Borrow<str>]
type.
The problem is in join_generic_copy
function.
-
The borrow result is first used for the length calculation.
Lines 152 to 161 in 3ffea60
-
Then, inside
spezialize_for_lengths
macro, the user-provided slice is borrowed again and the content is copied.
Lines 110 to 114 in 3ffea60
-
Finally, the length of the slice is set to the length calculated in step 1.
Line 179 in 3ffea60
Playground link, which demonstrates creating a non-UTF-8 string by only using safe Rust.