summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCasey Connolly <kcxt@postmarketos.org>2025-04-23 15:06:48 +0200
committerRich Felker <dalias@aerifal.cx>2025-05-27 10:06:37 -0400
commitfde29c04adbab9d5b081bf6717b5458188647f1c (patch)
tree67fd485b6e06c030e703097ce000fb50fd79b69e
parentae3a8c93a663b553e65f096498937083dad210d2 (diff)
downloadmusl-fde29c04adbab9d5b081bf6717b5458188647f1c.tar.gz
stdio: skip empty iovec when buffering is disabled
When buffering on a FILE is disabled we still send both iovecs, even though the first one is always empty. Clean things up by skipping the empty iovec instead.
-rw-r--r--src/stdio/__stdio_write.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/stdio/__stdio_write.c b/src/stdio/__stdio_write.c
index d2d89475..5356553d 100644
--- a/src/stdio/__stdio_write.c
+++ b/src/stdio/__stdio_write.c
@@ -11,6 +11,11 @@ size_t __stdio_write(FILE *f, const unsigned char *buf, size_t len)
size_t rem = iov[0].iov_len + iov[1].iov_len;
int iovcnt = 2;
ssize_t cnt;
+
+ if (!iov->iov_len) {
+ iov++;
+ iovcnt--;
+ }
for (;;) {
cnt = syscall(SYS_writev, f->fd, iov, iovcnt);
if (cnt == rem) {