This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
According to Jeff Johnston on 7/20/2009 10:34 AM: > This patch appears to fix the issue. Is it safe to probe fp->_flags > prior > to the _flockfile, in order to skip the lock if the stream is not > currently visiting a file? Or do I have to approach this in some other > manner? > > >> Probing fp->_flags should be ok. I do not think we should be setting >> errno and returning failure. There is nothing to flush. Running a test >> of fclose(stdout); fflush(stdout); on glibc returns 0 from fflush. >> Newlib should do the same. Also, Solaris set errno to EBADF, but still returned 0. So here's what I committed: > 2009-07-18 Eric Blake <ebb9@byu.net> > > Avoid a fault from locking a closed standard file. > * libc/stdio/fflush.c (_fflush_r): Give up early if stream has > been previously closed. Index: libc/stdio/fflush.c =================================================================== RCS file: /cvs/src/src/newlib/libc/stdio/fflush.c,v retrieving revision 1.13 diff -u -p -r1.13 fflush.c --- libc/stdio/fflush.c 31 Oct 2008 21:08:03 -0000 1.13 +++ libc/stdio/fflush.c 22 Jul 2009 02:16:31 -0000 @@ -93,6 +93,9 @@ _DEFUN(_fflush_r, (ptr, fp), CHECK_INIT (ptr, fp); + if (!fp->_flags) + return 0; + _flockfile (fp); t = fp->_flags; -- Don't work too hard, make some time for fun as well! Eric Blake ebb9@byu.net
Attachment:
signature.asc
Description: OpenPGP digital signature
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |