MISRA C:2023 Rule 22.6
The value of a pointer to a FILE shall not be used after the
            associated stream has been closed
Since R2024a
Description
Rule Definition
        The value of a pointer to a FILE shall not be used
                    after the associated stream has been closed1
      .
Rationale
The C Standard states that the value of a FILE* pointer is
        indeterminate after you close the stream associated with it. Using a
          FILE* pointer after closing the file stream is undefined
        behavior.
Polyspace Implementation
Polyspace® reports a violation when you access a pointer to a FILE
        after closing the stream. If you access the closed file stream multiple times, Polyspace reports violation on the first use.
Troubleshooting
If you expect a rule violation but do not see it, refer to Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
| Group: Resources | 
| Category: Mandatory | 
| AGC Category: Mandatory | 
Version History
Introduced in R2024a
See Also
Check MISRA C:2023
    (-misra-c-2023) | MISRA C:2012 Dir
                4.13 | MISRA C:2012 Rule
                21.6 | Use of previously
                closed resource
1 All MISRA coding rules and directives are © Copyright The MISRA Consortium Limited 2021.
The MISRA coding standards referenced in the Polyspace Bug Finder™ documentation are from the following MISRA standards:
- MISRA C:2004 
- MISRA C:2012 
- MISRA C:2023 
- MISRA C++:2008 
- MISRA C++:2023 
MISRA and MISRA C are registered trademarks of The MISRA Consortium Limited 2021.