Mercurial > flash_v2
changeset 1167:ebabafdc2d94
* 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()
| author | asl |
|---|---|
| date | Mon, 18 Aug 2003 19:45:33 +0000 |
| parents | c0cf37c14a8a |
| children | a8252a1c38ea |
| files | packages/language/c/libc/stdio/current/ChangeLog packages/language/c/libc/stdio/current/src/common/fclose.cxx packages/language/c/libc/stdio/current/src/common/fopen.cxx |
| diffstat | 3 files changed, 20 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/language/c/libc/stdio/current/ChangeLog +++ b/packages/language/c/libc/stdio/current/ChangeLog @@ -1,3 +1,12 @@ +2003-08-12 Scott Wilkinson <scott@alliantnetworks.com> + + * 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 <andrew.lunn@ascom.ch> Knud Wöhler <woehler@ossi.fho-emden.de>
--- a/packages/language/c/libc/stdio/current/src/common/fclose.cxx +++ b/packages/language/c/libc/stdio/current/src/common/fclose.cxx @@ -80,7 +80,13 @@ fclose( FILE *stream ) Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; int i; Cyg_ErrNo err; - + + if (NULL == real_stream) + { + errno = EBADF; + return EOF; + } + Cyg_libc_stdio_files::lock(); // find the stream in the table @@ -92,8 +98,8 @@ fclose( FILE *stream ) if (i == FOPEN_MAX) // didn't find it { + Cyg_libc_stdio_files::unlock(); errno = EBADF; - return EOF; } // if @@ -101,6 +107,7 @@ fclose( FILE *stream ) if( err != ENOERR ) { + Cyg_libc_stdio_files::unlock(); errno = err; return EOF; }
--- a/packages/language/c/libc/stdio/current/src/common/fopen.cxx +++ b/packages/language/c/libc/stdio/current/src/common/fopen.cxx @@ -156,6 +156,7 @@ static FILE *fopen_inner( cyg_stdio_hand if (i == FOPEN_MAX) { // didn't find an empty slot errno = EMFILE; cyg_stdio_close( dev ); + Cyg_libc_stdio_files::unlock(); return NULL; } // if @@ -169,6 +170,7 @@ static FILE *fopen_inner( cyg_stdio_hand curr_stream = (Cyg_StdioStream *)malloc(sizeof(*curr_stream)); if (curr_stream == NULL) { cyg_stdio_close( dev ); + Cyg_libc_stdio_files::unlock(); errno = ENOMEM; return NULL; } // if
