From: John Hodge Date: Sat, 7 Sep 2013 15:02:41 +0000 (+0800) Subject: Usermode/libc - Fixed fflush not handling errors X-Git-Tag: rel0.15~261 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=263d8c11d3c4a00f03d7215e784fb261a7066715;p=tpg%2Facess2.git Usermode/libc - Fixed fflush not handling errors --- 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;