From 6e2bb7acf42589fb7130b039d0623e2ca42503dd Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Thu, 4 Sep 2014 22:21:17 -0400 Subject: fix multiple stdio functions' behavior on zero-length operations previously, fgets, fputs, fread, and fwrite completely omitted locking and access to the FILE object when their arguments yielded a zero length read or write operation independent of the FILE state. this optimization was invalid; it wrongly skipped marking the stream as byte-oriented (a C conformance bug) and exposed observably missing synchronization (a POSIX conformance bug) where one of these functions could wrongly complete despite another thread provably holding the lock. --- src/stdio/fwrite.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/stdio/fwrite.c') diff --git a/src/stdio/fwrite.c b/src/stdio/fwrite.c index d5f6542d..81ec271e 100644 --- a/src/stdio/fwrite.c +++ b/src/stdio/fwrite.c @@ -28,7 +28,6 @@ size_t __fwritex(const unsigned char *restrict s, size_t l, FILE *restrict f) size_t fwrite(const void *restrict src, size_t size, size_t nmemb, FILE *restrict f) { size_t k, l = size*nmemb; - if (!l) return l; FLOCK(f); k = __fwritex(src, l, f); FUNLOCK(f); -- cgit v1.2.3-70-g09d2