# HG changeset patch # User jlarmour # Date 1079368317 0 # Node ID b6cb710a33b6070f7ab90d59e42772bebe390f1f # Parent 40a7aad7873c4fd4a2aee9849554b56428bc8d16 * src/common/fileops.cxx (tmpnam): Only close if open() succeded. diff --git a/packages/language/c/libc/stdio/current/ChangeLog b/packages/language/c/libc/stdio/current/ChangeLog --- a/packages/language/c/libc/stdio/current/ChangeLog +++ b/packages/language/c/libc/stdio/current/ChangeLog @@ -1,3 +1,7 @@ +2004-03-15 Jonathan Larmour + + * src/common/fileops.cxx (tmpnam): Only close if open() succeded. + 2004-03-12 Jonathan Larmour * src/input/vfscanf.cxx (vfscanf): Silence warning. diff --git a/packages/language/c/libc/stdio/current/src/common/fileops.cxx b/packages/language/c/libc/stdio/current/src/common/fileops.cxx --- a/packages/language/c/libc/stdio/current/src/common/fileops.cxx +++ b/packages/language/c/libc/stdio/current/src/common/fileops.cxx @@ -201,8 +201,9 @@ CYG_MACRO_END // s now points to a name candidate #ifdef CYGPKG_LIBC_STDIO_FILEIO int fd = open( s, O_RDONLY ); - close(fd); - if (fd < 0 && ENOENT == errno) // we have a winner + if (fd >= 0) + close(fd); + else if ( ENOENT == errno ) // we have a winner break; #else break; // no real filesystem, so just go with what we've come up with