We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5ca9c09 commit 23aac0aCopy full SHA for 23aac0a
1 file changed
java/ql/test/query-tests/Nullness/B.java
@@ -408,4 +408,32 @@ public void bitwise(Object x, boolean b) {
408
x.hashCode(); // NPE
409
}
410
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
428
+ // x is local to the loop iteration and thus cannot loop around and reach the sink
429
430
431
432
433
434
435
+ x.hashCode(); // OK
436
437
438
439
0 commit comments