aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc/stdio/fflush.c
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2009-07-22 02:17:12 +0000
committerEric Blake <eblake@redhat.com>2009-07-22 02:17:12 +0000
commitd6438f13d10acf192955b98b3f3a3fd5948f211e (patch)
treef912d00d60ceb871d488e6c8045d4bb88bc733d7 /newlib/libc/stdio/fflush.c
parentdc176ff60c5d8bb316d1f012c1ae542939648ceb (diff)
downloadnewlib-d6438f13d10acf192955b98b3f3a3fd5948f211e.zip
newlib-d6438f13d10acf192955b98b3f3a3fd5948f211e.tar.gz
newlib-d6438f13d10acf192955b98b3f3a3fd5948f211e.tar.bz2
Avoid a fault from locking a closed standard file.
* libc/stdio/fflush.c (_fflush_r): Give up early if stream has been previously closed.
Diffstat (limited to 'newlib/libc/stdio/fflush.c')
-rw-r--r--newlib/libc/stdio/fflush.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/newlib/libc/stdio/fflush.c b/newlib/libc/stdio/fflush.c
index 218940d..bc208ec 100644
--- a/newlib/libc/stdio/fflush.c
+++ b/newlib/libc/stdio/fflush.c
@@ -93,6 +93,9 @@ _DEFUN(_fflush_r, (ptr, fp),
CHECK_INIT (ptr, fp);
+ if (!fp->_flags)
+ return 0;
+
_flockfile (fp);
t = fp->_flags;