This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
fclose() / fopen()
- To: egcs-bugs at cygnus dot com
- Subject: fclose() / fopen()
- From: "Rafi Dery" <rafi_dery at hotmail dot com>
- Date: Thu, 14 Jan 1999 02:30:35 PST
- Cc: rafi_dery at hotmail dot com
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