mirror of
https://github.com/github/codeql.git
synced 2026-04-28 10:15:14 +02:00
Migrate Java code to separate QL repo.
This commit is contained in:
18
java/ql/src/Language Abuse/WrappedIteratorBad2.java
Normal file
18
java/ql/src/Language Abuse/WrappedIteratorBad2.java
Normal file
@@ -0,0 +1,18 @@
|
||||
class MySequence implements Iterable<MyElem> {
|
||||
// ... some reference to data
|
||||
final Iterator<MyElem> it = data.iterator();
|
||||
// Wrong: iteration state outside returned iterator
|
||||
public Iterator<MyElem> iterator() {
|
||||
return new Iterator<MyElem>() {
|
||||
public boolean hasNext() {
|
||||
return it.hasNext();
|
||||
}
|
||||
public MyElem next() {
|
||||
return transformElem(it.next());
|
||||
}
|
||||
public void remove() {
|
||||
// ...
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user