title: Double free error on fclose() on previously closed file handle
body: <p>I have a class that contains file handle <code>fHandle</code> that points to an open file. Now, it can be closed by any one of the multiple routines and that is based on dynamic run of the program.</p>
  
  <p>To be sure that a file is indeed closed, I put simple snippet in my destructor: <code>if(fHandle!=NULL) fclose(fHandle);</code>. Turns out, if one of the routines had previously closed this file, then the running the destructor snippet causes double free operation and I get <code>**glib detected**</code> error message.</p>
  
  <p>How do I make sure that I don't close the file handle that has previously been closed (apart from putting <code>NULL</code> check)?</p>