CWE
Home > CWE List > CWE- Individual Dictionary Definition (1.1)  
Search by ID:

CWE-584: Return Inside Finally Block

Individual Definition in a New Window
Return Inside Finally Block
Status: Draft
Weakness ID: 584 (Weakness Base)
Description
Summary

The code has a return statement inside a finally block, which will cause any thrown exception in the try block to be discarded.

Potential Mitigations

Do not use a return statement inside the finally block. The finally block should have "cleanup" code.

Demonstrative Examples

In the following code excerpt, the IllegalArgumentException will never be delivered to the caller. The finally block will cause the exception to be discarded.

try {
...
throw IllegalArgumentException();
}
finally {
return r;
}
Relationships
NatureTypeIDNameView(s) this relationship pertains toView(s)
ChildOfWeakness ClassWeakness ClassWeakness Class705Incorrect Control Flow Scoping
Research Concepts (primary)1000
ChildOfCategoryCategory389Error Conditions, Return Values, Status Codes
Development Concepts (primary)699
Time of Introduction
* Implementation
Content History
Modifications
Eric Dalci. Cigital. 2008-07-01. (External)
updated Potential_Mitigations, Time_of_Introduction
CWE Content Team. MITRE. 2008-09-08. (Internal)
updated Relationships
Page Last Updated: November 24, 2008