Skip to content

Commit 0245270

Browse files
committed
Java: Fix bug in nullness
1 parent 9fc0793 commit 0245270

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

java/ql/lib/semmle/code/java/dataflow/Nullness.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ private Expr trackingVarGuard(
653653
result = integerGuard(trackvar.getAnAccess(), branch, k, isA)
654654
or
655655
exists(int k2 |
656-
result = integerGuard(trackvar.getAnAccess(), branch.booleanNot(), k2, true) and
656+
result = integerGuard(trackvar.getAnAccess(), branch, k2, true) and
657657
isA = false and
658658
k2 != k
659659
)

java/ql/test/query-tests/Nullness/B.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,6 @@ public void trackTest(Object o, int n) {
513513
int c = -1;
514514
if (maybe) { }
515515
if (c == 100) { return; }
516-
o.hashCode(); // NPE - false negative
516+
o.hashCode(); // NPE
517517
}
518518
}

java/ql/test/query-tests/Nullness/NullMaybe.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
| 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 |
2222
| 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 |
2323
| 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 |
24+
| 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 |
2425
| 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 |
2526
| 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 |
2627
| 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 |

0 commit comments

Comments
 (0)