From: John Hodge Date: Sat, 9 Feb 2013 11:56:55 +0000 (+0800) Subject: Usermode/libc - Fixed DIV0 in fread/fopen X-Git-Tag: rel0.15~579 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=b61c005e743f800ed53fb4e7da664edd1ade3fba;p=tpg%2Facess2.git Usermode/libc - Fixed DIV0 in fread/fopen --- diff --git a/Usermode/Libraries/libc.so_src/stdio.c b/Usermode/Libraries/libc.so_src/stdio.c index a85bb598..c2b405c1 100644 --- a/Usermode/Libraries/libc.so_src/stdio.c +++ b/Usermode/Libraries/libc.so_src/stdio.c @@ -264,6 +264,8 @@ EXPORT size_t fwrite(const void *ptr, size_t size, size_t num, FILE *fp) if(!fp || fp->FD == -1) return -1; + if( size == 0 || num == 0 ) + return 0; if( fp->FD == -2 ) { size_t avail = (fp->BufferSize - fp->Pos) / size; @@ -293,6 +295,8 @@ EXPORT size_t fread(void *ptr, size_t size, size_t num, FILE *fp) if(!fp || fp->FD == -1) return -1; + if( size == 0 || num == 0 ) + return 0; if( fp->FD == -2 ) { size_t avail = (fp->BufferSize - fp->Pos) / size;