mirror of
https://github.com/github/codeql.git
synced 2026-05-02 20:25:13 +02:00
Java: Document two FPs with unit tests.
This commit is contained in:
@@ -168,4 +168,44 @@ public class C {
|
||||
finalObj.hashCode(); // OK
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyBool(boolean b) {
|
||||
if (!b) {
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
|
||||
public void ex13(int[] a) {
|
||||
int i = 0;
|
||||
boolean b = false;
|
||||
Object obj = null;
|
||||
while (a[++i] != 0) {
|
||||
if (a[i] == 1) {
|
||||
obj = new Object();
|
||||
b = true;
|
||||
} else if (a[i] == 2) {
|
||||
verifyBool(b);
|
||||
obj.hashCode(); // NPE - false positive
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyNotNull(Object obj) {
|
||||
if (obj == null) {
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
|
||||
public void ex14(int[] a) {
|
||||
int i = 0;
|
||||
Object obj = null;
|
||||
while (a[++i] != 0) {
|
||||
if (a[i] == 1) {
|
||||
obj = new Object();
|
||||
} else if (a[i] == 2) {
|
||||
verifyNotNull(obj);
|
||||
obj.hashCode(); // NPE - false positive
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user