From: John Hodge Date: Fri, 26 Apr 2013 05:22:46 +0000 (+0800) Subject: Usermode/libc - Fixed back-seek of -1 when a write error occurs in buffering X-Git-Tag: rel0.15~517 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=4cec3cb45e1a5343c8791fb6bdd1d2b896d3f500;p=tpg%2Facess2.git Usermode/libc - Fixed back-seek of -1 when a write error occurs in buffering --- diff --git a/Usermode/Libraries/libc.so_src/stdio.c b/Usermode/Libraries/libc.so_src/stdio.c index 8f7ede00..d03231c3 100644 --- a/Usermode/Libraries/libc.so_src/stdio.c +++ b/Usermode/Libraries/libc.so_src/stdio.c @@ -389,6 +389,11 @@ size_t _fwrite_unbuffered(FILE *fp, size_t size, size_t num, const void *data) while( num -- ) { bytes = _SysWrite(fp->FD, data, size); + if( bytes == (size_t)-1 ) { + // Oops. + // TODO: Set error flag + break; + } if( bytes != size ) { _SysDebug("_fwrite_unbuffered: Oops, rollback %i/%i bytes!", bytes, size); _SysSeek(fp->FD, -bytes, SEEK_CUR);