mirror of
https://github.com/github/codeql.git
synced 2026-03-30 20:28:15 +02:00
Java: Add nullness test covering known FP.
This commit is contained in:
@@ -557,4 +557,23 @@ public class B {
|
||||
if (n > 100) s.hashCode(); // OK
|
||||
if (n == 42) s.hashCode(); // OK
|
||||
}
|
||||
|
||||
public void testFinally2(int[] xs) {
|
||||
String s = null;
|
||||
int i = 0;
|
||||
while (true) {
|
||||
try {
|
||||
int x = xs[i++];
|
||||
if (x == 0) {
|
||||
s = "foo";
|
||||
break;
|
||||
} else if (x == 1) {
|
||||
continue;
|
||||
}
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
s.hashCode(); // Spurious NPE - false positive
|
||||
// CFG reachability does not distinguish abrupt successors
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
| B.java:516:5:516:5 | o | Variable $@ may be null at this access as suggested by $@ null guard. | B.java:511:25:511:32 | o | o | B.java:512:22:512:30 | ... == ... | this |
|
||||
| B.java:535:7:535:8 | s2 | Variable $@ may be null at this access because of $@ assignment. | B.java:523:5:523:21 | String s2 | s2 | B.java:523:12:523:20 | s2 | this |
|
||||
| B.java:537:5:537:6 | s1 | Variable $@ may be null at this access because of $@ assignment. | B.java:522:5:522:21 | String s1 | s1 | B.java:522:12:522:20 | s1 | this |
|
||||
| B.java:576:5:576:5 | s | Variable $@ may be null at this access because of $@ assignment. | B.java:562:5:562:20 | String s | s | B.java:562:12:562:19 | s | this |
|
||||
| C.java:9:44:9:45 | a2 | Variable $@ may be null at this access as suggested by $@ null guard. | C.java:6:5:6:23 | long[][] a2 | a2 | C.java:7:34:7:54 | ... != ... | this |
|
||||
| C.java:9:44:9:45 | a2 | Variable $@ may be null at this access because of $@ assignment. | C.java:6:5:6:23 | long[][] a2 | a2 | C.java:6:14:6:22 | a2 | this |
|
||||
| C.java:10:17:10:18 | a3 | Variable $@ may be null at this access as suggested by $@ null guard. | C.java:8:5:8:21 | long[] a3 | a3 | C.java:9:38:9:58 | ... != ... | this |
|
||||
|
||||
Reference in New Issue
Block a user