...
Modifying a Collection
while iterating over it results in undefined behavior.
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
MSC06-J | Low | Probable | Medium | P4 | L3 |
Automated Detection
Some static analysis tools can detect cases where an iterator is being used after the source container of the iterator is modified.
Tool | Version | Checker | Description |
---|---|---|---|
Parasoft Jtest |
|
|
|
CERT. |
MSC06.ITMOD |
Do not modify collection while iterating over it | |||||||||
PVS-Studio |
| V6053 |
Related Vulnerabilities
The Apache Harmony bug HARMONY-6236 documents an ArrayList
breaking when given concurrent collections as input.
Bibliography
...
...