X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Fstdio%2Ffread.c;h=aef75f7376f700dd584bf346ab1b7b17717ab097;hb=b6e1fe0d5e78dac647e85d49c2d537bb071ba49e;hp=c461256c3b0de4d6af84c0df426710fa121ddc06;hpb=c6d441e3a246370d9c459396ec22b096db93850e;p=musl diff --git a/src/stdio/fread.c b/src/stdio/fread.c index c461256c..aef75f73 100644 --- a/src/stdio/fread.c +++ b/src/stdio/fread.c @@ -7,12 +7,12 @@ size_t fread(void *restrict destv, size_t size, size_t nmemb, FILE *restrict f) { unsigned char *dest = destv; size_t len = size*nmemb, l = len, k; - - /* Never touch the file if length is zero.. */ - if (!l) return 0; + if (!size) nmemb = 0; FLOCK(f); + f->mode |= f->mode-1; + if (f->rend - f->rpos > 0) { /* First exhaust the buffer. */ k = MIN(f->rend - f->rpos, l);