diff options
Diffstat (limited to 'lib/libc/stdio/fwrite.c')
-rw-r--r-- | lib/libc/stdio/fwrite.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/libc/stdio/fwrite.c b/lib/libc/stdio/fwrite.c index 999d595..cf52e42 100644 --- a/lib/libc/stdio/fwrite.c +++ b/lib/libc/stdio/fwrite.c @@ -57,8 +57,15 @@ fwrite(buf, size, count, fp) struct __suio uio; struct __siov iov; + /* + * ANSI and SUSv2 require a return value of 0 if size or count are 0. + */ + n = count * size; + if (n == 0) + return (0); + iov.iov_base = (void *)buf; - uio.uio_resid = iov.iov_len = n = count * size; + uio.uio_resid = iov.iov_len = n; uio.uio_iov = &iov; uio.uio_iovcnt = 1; |