Content-Length: 303573 | pFad | http://github.com/github/codeql/commit/#start-of-content

68922EA2 Merge pull request #20171 from aschackmull/java/nullness-fn · github/codeql@1823355 · GitHub
Skip to content

Commit 1823355

Browse files
authored
Merge pull request #20171 from aschackmull/java/nullness-fn
Java: document nullness false negative as qltest
2 parents 9427428 + 23aac0a commit 1823355

File tree

1 file changed

+28
-0
lines changed
  • java/ql/test/query-tests/Nullness

1 file changed

+28
-0
lines changed

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,4 +408,32 @@ public void bitwise(Object x, boolean b) {
408408
x.hashCode(); // NPE
409409
}
410410
}
411+
412+
public void corrCondLoop1(boolean a[]) {
413+
Object x = new Object();
414+
for (int i = 0; i < a.length; i++) {
415+
boolean b = a[i];
416+
if (b) {
417+
x = null;
418+
}
419+
if (!b) {
420+
x.hashCode(); // NPE - false negative
421+
}
422+
// flow can loop around from one iteration to the next
423+
}
424+
}
425+
426+
public void corrCondLoop2(boolean a[]) {
427+
for (int i = 0; i < a.length; i++) {
428+
// x is local to the loop iteration and thus cannot loop around and reach the sink
429+
Object x = new Object();
430+
boolean b = a[i];
431+
if (b) {
432+
x = null;
433+
}
434+
if (!b) {
435+
x.hashCode(); // OK
436+
}
437+
}
438+
}
411439
}

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/github/codeql/commit/#start-of-content

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy