From 500c6886c654fd45e4926990fee2c61d816be197 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Wed, 10 Feb 2016 19:44:19 -0500 Subject: fix return value for fread/fwrite when size argument is 0 when the size argument was zero but nmemb was nonzero, these functions were returning nmemb, despite no data having been written. conceptually this is not wrong, but the standard requires a return value of zero in this case. --- src/stdio/fread.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/stdio/fread.c') diff --git a/src/stdio/fread.c b/src/stdio/fread.c index 33a65f58..aef75f73 100644 --- a/src/stdio/fread.c +++ b/src/stdio/fread.c @@ -7,6 +7,7 @@ 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; + if (!size) nmemb = 0; FLOCK(f); -- cgit v1.2.1