? fopen_close.patch Index: c/libc/stdio/current/ChangeLog =================================================================== RCS file: /home/cvs/ecos/packages/language/c/libc/stdio/current/ChangeLog,v retrieving revision 1.1.1.2 diff -u -r1.1.1.2 ChangeLog --- c/libc/stdio/current/ChangeLog 30 Jun 2003 23:22:48 -0000 1.1.1.2 +++ c/libc/stdio/current/ChangeLog 12 Aug 2003 22:36:21 -0000 @@ -1,3 +1,12 @@ +2003-08-12 Scott Wilkinson + + * src/common/fclose.cxx (fclose): fclose would seg-fault if passed + NULL FILE pointer. Now returns error. Also cleaned up some exit + paths to call Cyg_libc_stdio_files::unlock() + + * src/common/fopen.cxx (fopen): Cleaned up some exit paths to call + Cyg_libc_stdio_files::unlock() + 2003-06-10 Andrew Lunn Knud Wöhler Index: c/libc/stdio/current/src/common/fclose.cxx =================================================================== RCS file: /home/cvs/ecos/packages/language/c/libc/stdio/current/src/common/fclose.cxx,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 fclose.cxx --- c/libc/stdio/current/src/common/fclose.cxx 14 May 2003 17:49:56 -0000 1.1.1.1 +++ c/libc/stdio/current/src/common/fclose.cxx 12 Aug 2003 22:36:21 -0000 @@ -81,6 +81,12 @@ int i; Cyg_ErrNo err; + if (real_stream == NULL) + { + errno = EBADF; + return EOF; + } + Cyg_libc_stdio_files::lock(); // find the stream in the table @@ -93,7 +99,7 @@ if (i == FOPEN_MAX) // didn't find it { errno = EBADF; - + Cyg_libc_stdio_files::unlock(); return EOF; } // if @@ -102,6 +108,7 @@ if( err != ENOERR ) { errno = err; + Cyg_libc_stdio_files::unlock(); return EOF; } Index: c/libc/stdio/current/src/common/fopen.cxx =================================================================== RCS file: /home/cvs/ecos/packages/language/c/libc/stdio/current/src/common/fopen.cxx,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 fopen.cxx --- c/libc/stdio/current/src/common/fopen.cxx 14 May 2003 17:49:56 -0000 1.1.1.1 +++ c/libc/stdio/current/src/common/fopen.cxx 12 Aug 2003 22:36:21 -0000 @@ -156,6 +156,7 @@ if (i == FOPEN_MAX) { // didn't find an empty slot errno = EMFILE; cyg_stdio_close( dev ); + Cyg_libc_stdio_files::unlock(); return NULL; } // if @@ -170,6 +171,7 @@ if (curr_stream == NULL) { cyg_stdio_close( dev ); errno = ENOMEM; + Cyg_libc_stdio_files::unlock(); return NULL; } // if