Main Content
Use of previously closed resource
Function operates on a previously closed stream
Description
This defect occurs when a function operates on a stream that you closed earlier in your code.
Risk
The standard states that the value of a FILE*
pointer
is indeterminate after you close the stream associated with it. Operations
using the FILE*
pointer can produce unintended
results.
Fix
One possible fix is to close the stream only at the end of operations. Another fix is to reopen the stream before using it again.
Examples
Result Information
Group: Resource management |
Language: C | C++ |
Default: On for handwritten code, off for generated code |
Command-Line Syntax: CLOSED_RESOURCE_USE |
Impact: High |
Version History
Introduced in R2015b
See Also
Find defects (-checkers)
| MISRA C:2012 Rule 22.6
Topics
- Interpret Bug Finder Results in Polyspace Desktop User Interface
- Interpret Bug Finder Results in Polyspace Access Web Interface (Polyspace Access)
- Address Results in Polyspace User Interface Through Bug Fixes or Justifications
- Address Results in Polyspace Access Through Bug Fixes or Justifications (Polyspace Access)