Usermode/libc - Fixed back-seek of -1 when a write error occurs in buffering
authorJohn Hodge <[email protected]>
Fri, 26 Apr 2013 05:22:46 +0000 (13:22 +0800)
committerJohn Hodge <[email protected]>
Fri, 26 Apr 2013 05:22:46 +0000 (13:22 +0800)
Usermode/Libraries/libc.so_src/stdio.c

index 8f7ede0..d03231c 100644 (file)
@@ -389,6 +389,11 @@ size_t _fwrite_unbuffered(FILE *fp, size_t size, size_t num, const void *data)
        while( num -- )\r
        {\r
                bytes = _SysWrite(fp->FD, data, size);\r
+               if( bytes == (size_t)-1 ) {\r
+                       // Oops.\r
+                       // TODO: Set error flag\r
+                       break;\r
+               }\r
                if( bytes != size ) {\r
                        _SysDebug("_fwrite_unbuffered: Oops, rollback %i/%i bytes!", bytes, size);\r
                        _SysSeek(fp->FD, -bytes, SEEK_CUR);\r

UCC git Repository :: git.ucc.asn.au