github / github/codeql

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

Aberta
#1,061 0 comentários 0 reações 0 responsáveis Ver no GitHub
false-positive Java
Linguagem predominante
CodeQL
Estrelas
10.1k
Forks
2.1k
Merge médio
2d 15h
PRs com merge (30d)
141

Descrição

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

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.