Files
codeql/java/ql/test/query-tests/security/CWE-835/semmle/tests/InfiniteLoop.java
2018-08-30 10:48:05 +01:00

14 lines
338 B
Java

class Test {
public void bad() {
for (int i=0; i<10; i++) {
for (int j=0; i<10; j++) {
// potentially infinite loop due to test on wrong variable
if (shouldBreak()) break;
}
}
}
private boolean shouldBreak() {
return Math.random() < 0.5;
}
}