This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

fclose() / fopen()


Hi,

The following piece of code, compiled with egcs-2.90.27 (egcs-1.0.2 
release), causes Segmentation fault:

...
FILE * f_write;

f_write = fopen("somelog", "a");
if (!f_write)
   return ERR;

... 
fclose(f_write);

THE SIGSEGV is caused upon fclose()-ing the file.
using gdb, I have noticed that it happens due to "weired" FILE 
structure, with funny field-values like _fileno=-1, etc.

Could this happen? As much as i know, if the open() inside fopen() 
fails, fopen() should return NULL, not a FILE struct with fileno=-1 !

Please advise,

Rafi.

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]