mirror of
https://github.com/github/codeql.git
synced 2026-04-29 18:55:14 +02:00
Add tests for always-locked fields
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package test.cwe367.semmle.tests;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
|
||||
class FieldAlwaysLocked {
|
||||
|
||||
Hashtable field;
|
||||
|
||||
public FieldAlwaysLocked() {
|
||||
field = new Hashtable();
|
||||
}
|
||||
|
||||
protected synchronized void checkOut() {
|
||||
Object o;
|
||||
if (field.size() > 0) {
|
||||
Enumeration e = field.keys(); // $ SPURIOUS: Alert
|
||||
while (e.hasMoreElements()) {
|
||||
o = e.nextElement();
|
||||
field.remove(o); // $ SPURIOUS: Alert
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user