diff options
| author | Rich Felker <dalias@aerifal.cx> | 2011-09-04 16:06:38 -0400 | 
|---|---|---|
| committer | Rich Felker <dalias@aerifal.cx> | 2011-09-04 16:06:38 -0400 | 
| commit | 22e4542348352235614b57948025bdd0cc30dc32 (patch) | |
| tree | e28faf749359351f6fa20f8f37d974d1fb063cc2 /src | |
| parent | f81279ff583ef81bc88a46dd1d0140fb6e0ed222 (diff) | |
| download | musl-22e4542348352235614b57948025bdd0cc30dc32.tar.gz | |
fmemopen: fix eof handling, hopefully right this time
Diffstat (limited to 'src')
| -rw-r--r-- | src/stdio/fmemopen.c | 7 | 
1 files changed, 4 insertions, 3 deletions
| diff --git a/src/stdio/fmemopen.c b/src/stdio/fmemopen.c index ddb24331..e2adfb22 100644 --- a/src/stdio/fmemopen.c +++ b/src/stdio/fmemopen.c @@ -24,8 +24,10 @@ static size_t mread(FILE *f, unsigned char *buf, size_t len)  {  	struct cookie *c = f->cookie;  	size_t rem = c->size - c->pos; -	if (!len) return 0; -	if (len > rem) len = rem; +	if (len > rem) { +		len = rem; +		f->flags |= F_EOF; +	}  	memcpy(buf, c->buf+c->pos, len);  	c->pos += len;  	rem -= len; @@ -34,7 +36,6 @@ static size_t mread(FILE *f, unsigned char *buf, size_t len)  	f->rend = f->buf + rem;  	memcpy(f->rpos, c->buf+c->pos, rem);  	c->pos += rem; -	if (!len) f->flags |= F_EOF;  	return len;  } | 
