CWE-460
Improper Cleanup on Thrown Exception
AI Translation Available
The product does not clean up its state or incorrectly cleans up its state when an exception is thrown, leading to unexpected state or control flow.
Status
draft
Abstraction
base
Likelihood
medium
Affected Platforms
C
C#
C++
Java
Extended Description
AI Translation
Often, when functions or loops become complicated, some level of resource cleanup is needed throughout execution. Exceptions can disturb the flow of the code and prevent the necessary cleanup from happening.
Technical Details
AI Translation
Common Consequences
other
Impacts
varies by context
Detection Methods
automated static analysis
Potential Mitigations
Phases:
implementation
Descriptions:
•
If one breaks from a loop or function by throwing an exception, make sure that cleanup happens or that you should exit the program. Use throwing exceptions sparsely.