Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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.

ToolVersionCheckerDescription
Parasoft Jtest
Include Page
java:
Parasoft_V
java:
Parasoft_V
BD
CERT.
CO
MSC06.ITMOD
Implemented
Do not modify collection while iterating over it
PVS-Studio

Include Page
PVS-Studio_V
PVS-Studio_V

V6053

Related Vulnerabilities

The Apache Harmony bug HARMONY-6236 documents an ArrayList breaking when given concurrent collections as input.

Bibliography

...


...

  Image Modified