mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 15:11:30 +00:00
Check array lengths to prevent OOB access
This commit is contained in:
parent
c4c9d9fc62
commit
7e7a33c726
1 changed files with 3 additions and 0 deletions
|
@ -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";
|
||||
|
|
Loading…
Reference in a new issue