-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea9ecf0
commit 65680c0
Showing
2 changed files
with
21 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
{ | ||
} | ||
"tags": [ | ||
"clippy", | ||
"out_of_bounds_indexing" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,37 @@ | ||
FIXME: add a description | ||
|
||
// If you want to factorize the description uncomment the following line and create the file. | ||
//include::../description.adoc[] | ||
|
||
== Why is this an issue? | ||
|
||
FIXME: remove the unused optional headers (that are commented out) | ||
An array index out-of-bounds panic is a bug class that occurs in Rust when a | ||
program tries to access an array element that does not exist. | ||
This bug can cause your program to crash or behave unexpectedly. | ||
|
||
//=== What is the potential impact? | ||
include::../impact.adoc[] | ||
|
||
== How to fix it | ||
//== How to fix it in FRAMEWORK NAME | ||
|
||
To fix an array index out of bounds panic in Rust, you should always ensure | ||
that you are accessing array elements within the bounds of the array. | ||
|
||
=== Code examples | ||
|
||
==== Noncompliant code example | ||
|
||
[source,rust,diff-id=1,diff-type=noncompliant] | ||
---- | ||
FIXME | ||
let x = [1, 2, 3, 4]; | ||
x[9]; // Out of bounds indexing | ||
---- | ||
|
||
==== Compliant solution | ||
|
||
[source,rust,diff-id=1,diff-type=compliant] | ||
---- | ||
FIXME | ||
---- | ||
|
||
//=== How does this work? | ||
let x = [1, 2, 3, 4]; | ||
//=== Pitfalls | ||
|
||
//=== Going the extra mile | ||
x[0]; | ||
---- | ||
|
||
== Resources | ||
=== Documentation | ||
|
||
//== Resources | ||
//=== Documentation | ||
//=== Articles & blog posts | ||
//=== Conference presentations | ||
//=== Standards | ||
//=== External coding guidelines | ||
//=== Benchmarks | ||
* Clippy Lints - https://rust-lang.github.io/rust-clippy/master/index.html#out_of_bounds_indexing |