From e5d9109aabc163148fe4cf07f9d36aff9b067fb6 Mon Sep 17 00:00:00 2001 From: Eitan Adler Date: Wed, 30 May 2012 04:06:38 +0000 Subject: [PATCH] Only set _w to 0 when the file stream is not currently reading. Without this fflush may fail to write data in the buffer. PR: kern/137819 Submitted by: Eric Blake Reviewed by: theraven Approved by: cperciva MFC after: 2 weeks --- lib/libc/stdio/fpurge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libc/stdio/fpurge.c b/lib/libc/stdio/fpurge.c index 6a2c70c3c5da..148e490eafe2 100644 --- a/lib/libc/stdio/fpurge.c +++ b/lib/libc/stdio/fpurge.c @@ -62,7 +62,7 @@ fpurge(fp) FREEUB(fp); fp->_p = fp->_bf._base; fp->_r = 0; - fp->_w = fp->_flags & (__SLBF|__SNBF) ? 0 : fp->_bf._size; + fp->_w = fp->_flags & (__SLBF|__SNBF|__SRD) ? 0 : fp->_bf._size; retval = 0; } FUNLOCKFILE(fp);