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};
13
13
declare_clippy_lint ! {
14
14
/// ### What it does
15
15
/// 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()`.
18
18
///
19
19
/// ### Why is this bad?
20
20
/// 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`.
22
23
///
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.
24
26
///
25
27
/// ### Known Problems
26
28
/// This lint only checks directly adjacent statements.
You can’t perform that action at this time.
0 commit comments