github / github/codeql

Java: FP in java/index-out-of-bounds when index known to be less than the length of the array

Aperta
#1,061 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
false-positive Java
Lingua principale
CodeQL
Stelle
10.1k
Fork
2.1k
Merge medio
2g 15h
PR unite (30g)
141

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.