File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -13,14 +13,16 @@ use rustc_span::{sym, Span};
1313declare_clippy_lint ! {
1414 /// ### What it does
1515 /// Checks for `set_len()` call that creates `Vec` with uninitialized elements.
16- /// This is commonly caused by calling `set_len()` right after after calling
17- /// ` with_capacity()` or `reserve()`.
16+ /// This is commonly caused by calling `set_len()` right after allocating or
17+ /// reserving a buffer with `new()`, `default()`, ` with_capacity()`, or `reserve()`.
1818 ///
1919 /// ### Why is this bad?
2020 /// It creates a `Vec` with uninitialized data, which leads to
21- /// undefined behavior with most safe operations.
21+ /// undefined behavior with most safe operations. Notably, uninitialized
22+ /// `Vec<u8>` must not be used with generic `Read`.
2223 ///
23- /// Notably, uninitialized `Vec<u8>` must not be used with generic `Read`.
24+ /// Moreover, calling `set_len()` on a `Vec` created with `new()` or `default()`
25+ /// creates out-of-bound values that lead to heap memory corruption when used.
2426 ///
2527 /// ### Known Problems
2628 /// This lint only checks directly adjacent statements.
You can’t perform that action at this time.
0 commit comments