From 263d8c11d3c4a00f03d7215e784fb261a7066715 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sat, 7 Sep 2013 23:02:41 +0800 Subject: [PATCH] Usermode/libc - Fixed fflush not handling errors --- Usermode/Libraries/libc.so_src/stdio.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Usermode/Libraries/libc.so_src/stdio.c b/Usermode/Libraries/libc.so_src/stdio.c index 7082f235..315f6985 100644 --- a/Usermode/Libraries/libc.so_src/stdio.c +++ b/Usermode/Libraries/libc.so_src/stdio.c @@ -300,9 +300,12 @@ int _fflush_int(FILE *fp) case FILE_FLAG_MODE_APPEND: _SysSeek(fp->FD, fp->BufferOfs, SEEK_SET); len = _SysWrite(fp->FD, fp->Buffer, fp->BufferPos); - if( len < fp->BufferPos ) + if( len != fp->BufferPos ) ret = 1; - fp->BufferPos -= len; + if( len <= fp->BufferPos ) + { + fp->BufferPos -= len; + } fp->BufferOfs = _SysTell(fp->FD); break; @@ -312,7 +315,13 @@ int _fflush_int(FILE *fp) len = _SysWrite(fp->FD, fp->Buffer, fp->BufferPos); if( len != fp->BufferPos ) ret = 1; - fp->BufferPos -= len; + if( len <= fp->BufferPos ) + { + fp->BufferPos -= len; + } + //else { + // _SysDebug("Flush of %i failed, %s", fp->FD, strerror(errno)); + //} break; default: break; -- 2.20.1