mirror of
https://github.com/github/codeql.git
synced 2026-04-28 10:15:14 +02:00
Java: More nullness qltests.
This commit is contained in:
@@ -471,4 +471,29 @@ public class B {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loopCorrTest3(String[] ss) {
|
||||
Object x = null;
|
||||
Object t = null;
|
||||
for (String s : ss) {
|
||||
if (t == null) {
|
||||
t = s;
|
||||
} else {
|
||||
if (t instanceof String) {
|
||||
x = new Object();
|
||||
t = new Object();
|
||||
}
|
||||
// correctly guarded by t: null -> String -> Object
|
||||
x.hashCode(); // Spurious NPE - false positive
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void initCorr(boolean b) {
|
||||
Object o2 = b ? null : "";
|
||||
if (b)
|
||||
o2 = "";
|
||||
else
|
||||
o2.hashCode(); // OK
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
| B.java:408:7:408:7 | x | Variable $@ may be null at this access as suggested by $@ null guard. | B.java:374:23:374:30 | x | x | B.java:375:23:375:31 | ... != ... | this |
|
||||
| B.java:448:9:448:9 | x | Variable $@ may be null at this access because of $@ assignment. | B.java:442:5:442:28 | Object x | x | B.java:446:9:446:16 | ...=... | this |
|
||||
| B.java:465:9:465:9 | x | Variable $@ may be null at this access because of $@ assignment. | B.java:458:5:458:28 | Object x | x | B.java:470:9:470:16 | ...=... | this |
|
||||
| B.java:487:9:487:9 | x | Variable $@ may be null at this access because of $@ assignment. | B.java:476:5:476:20 | Object x | x | B.java:476:12:476:19 | x | 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