summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/fflush.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/stdio/fflush.c')
-rw-r--r--lib/libc/stdio/fflush.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/libc/stdio/fflush.c b/lib/libc/stdio/fflush.c
index 5c1eaa1..55a6a2a 100644
--- a/lib/libc/stdio/fflush.c
+++ b/lib/libc/stdio/fflush.c
@@ -113,9 +113,15 @@ __sflush(FILE *fp)
fp->_p = p;
fp->_w = t & (__SLBF|__SNBF) ? 0 : fp->_bf._size;
+ if (n <= 0)
+ return (0);
+ if ((fp->_flags & __SAPP) && _sseek(fp, (fpos_t)0, SEEK_END) == -1)
+ goto err;
+ fp->_flags &= ~__SOFF; /* In case FAPPEND mode is set. */
for (; n > 0; n -= t, p += t) {
t = (*fp->_write)(fp->_cookie, (char *)p, n);
if (t <= 0) {
+ err:
fp->_flags |= __SERR;
return (EOF);
}
OpenPOWER on IntegriCloud