Java: FP in java/index-out-of-bounds when index known to be less than the length of the array
Ouverte
false-positive
Java
- Langage dominant
- CodeQL
- Étoiles
- 10.1k
- Forks
- 2.1k
- Merge moyen
- 2 j 15 h
- PR mergées (30 j)
- 141
Description
See: https://discuss.lgtm.com/t/java-false-positives/1787/2
```java
int x = ++i;
int y = ++i;
if (y < sb.length) {
byte[] hex = {sb[x], sb[y]};
^^^^^ -- flagged as alert
```
We know that (modulo overflow):
* `x` = `y - 1` --> `x` < `y`
* `y` < `sb.length`
Example: https://lgtm.com/projects/g/apache/accumulo/snapshot/b672a845ed56e9fd521ab85462cb6c45baa9abad/files/core/src/main/java/org/apache/accumulo/core/iterators/conf/ColumnSet.java?sort=name&dir=ASC&mode=heatmap#xb5a588dd1daff67e:1
Guide de contribution
Ouvrir le guide de contribution
Évaluation
Cette issue n'a pas encore été évaluée.