diff options
| author | Philipp Hansch <dev@phansch.net> | 2018-11-23 21:29:27 +0100 |
|---|---|---|
| committer | Philipp Hansch <dev@phansch.net> | 2018-12-12 07:31:04 +0100 |
| commit | 7e7a33c72695bae3316bf8b211e4bfb698ed7686 (patch) | |
| tree | 20a7dddac1a763992d84a9f8e7a95c18787d4a1a | |
| parent | c4c9d9fc62eb244c0f219cfbf23f19b9240c2827 (diff) | |
| download | rust-7e7a33c72695bae3316bf8b211e4bfb698ed7686.tar.gz rust-7e7a33c72695bae3316bf8b211e4bfb698ed7686.zip | |
Check array lengths to prevent OOB access
| -rw-r--r-- | clippy_lints/src/explicit_write.rs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/clippy_lints/src/explicit_write.rs b/clippy_lints/src/explicit_write.rs index 65fa6aeec0b..e2b643c4de6 100644 --- a/clippy_lints/src/explicit_write.rs +++ b/clippy_lints/src/explicit_write.rs @@ -52,9 +52,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { if let ExprKind::MethodCall(ref write_fun, _, ref write_args) = unwrap_args[0].node; // Obtain the string that should be printed + if write_args.len() > 1; if let ExprKind::Call(_, ref output_args) = write_args[1].node; + if output_args.len() > 0; if let ExprKind::AddrOf(_, ref output_string_expr) = output_args[0].node; if let ExprKind::Array(ref string_exprs) = output_string_expr.node; + if string_exprs.len() > 0; if let ExprKind::Lit(ref lit) = string_exprs[0].node; if let LitKind::Str(ref write_output, _) = lit.node; if write_fun.ident.name == "write_fmt"; |
