Merge pull request #372 from aschackmull/java/rangeanalysis-array-phinodes

Approved by yh-semmle
This commit is contained in:
semmle-qlci
2018-10-29 13:02:58 +00:00
committed by GitHub
5 changed files with 100 additions and 26 deletions

View File

@@ -34,7 +34,7 @@ public class A {
}
for (int i = 0; i < arr1.length; ) {
sum += arr1[i++]; // OK
sum += arr1[i++]; // OK - FP
sum += arr1[i++]; // OK
i += 2;
}
for (int i = 0; i < arr2.length; ) {
@@ -162,4 +162,17 @@ public class A {
sum += b[i] + b[i + 1]; // OK
}
}
void m13(int n) {
int[] a = null;
if (n > 0) {
a = n > 0 ? new int[3 * n] : null;
}
int sum;
if (a != null) {
for (int i = 0; i < a.length; i += 3) {
sum += a[i + 2]; // OK
}
}
}
}

View File

@@ -1,6 +1,5 @@
| A.java:16:14:16:17 | ...[...] | This array access might be out of bounds, as the index might be equal to the array length. |
| A.java:23:21:23:28 | ...[...] | This array access might be out of bounds, as the index might be equal to the array length. |
| A.java:37:14:37:22 | ...[...] | This array access might be out of bounds, as the index might be equal to the array length. |
| A.java:42:14:42:22 | ...[...] | This array access might be out of bounds, as the index might be equal to the array length. |
| A.java:46:14:46:22 | ...[...] | This array access might be out of bounds, as the index might be equal to the array length. |
| A.java:55:14:55:19 | ...[...] | This array access might be out of bounds, as the index might be equal to the array length. |