A file was closed twice.
When a file handle is closed, resources associated with that file are released. Calling fclose twice will reference memory after it has been freed. This can have unpredictable consequences, especially if that storage has been reused for another purpose.
ID |
Observation |
Description |
---|---|---|
1 |
Resource deallocation |
The place the file was closed the first time |
2 |
Resource deallocation |
The place the file was closed the second time |
#include <stdio.h> int main(int argc, char **argv) { FILE *fp = fopen("newfile", "w"); if (fp != 0) { fclose(fp); fclose(fp); // bad } }
Copyright © 2010, Intel Corporation. All rights reserved.