MISRA.RESOURCES.FILE.USE_AFTER_CLOSE.2012The value of a pointer to a FILE shall not be used after the associated stream has been closed MISRA C 2012 Rule 22.6: The value of a pointer to a FILE shall not be used after the associated stream has been closedC99 [Undefined 140] Category: Mandatory Analysis: Undecidable, System Applies to: C90, C99 RationaleThe Standard states that the value of a FILE pointer is indeterminate after a close operation on a stream. Example#include <stdio.h> void fn ( void ) { FILE *fp; void *p; fp = fopen ( "tm p", "w" ); if ( fp == NULL ) { error_action ( ); } fclose ( fp ); fprintf ( fp, "?" ); /* Non-compliant */ p = fp; /* Non-compliant */ } See alsoDir 4.13, Rule 21.6 |