aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2018-08-29 23:53:45 -0400
committerRich Felker <dalias@aerifal.cx>2018-08-29 23:53:45 -0400
commita43a7b215cf7b71d1371c63927c17bae7177aa95 (patch)
treec3766205559ed56d7f281a584a4be39cac13dc64 /src
parentf1791f42ef6d22e68dfc1ee45c0a478b156ce46d (diff)
downloadmusl-a43a7b215cf7b71d1371c63927c17bae7177aa95.zip
musl-a43a7b215cf7b71d1371c63927c17bae7177aa95.tar.gz
musl-a43a7b215cf7b71d1371c63927c17bae7177aa95.tar.bz2
make vfprintf set stream orientation even for zero-length output
if no output is produced, no underlying fwrite will ever be called, but byte-oriented printf functions are still required to set the orientation of the stream to byte-oriented. call __towrite explicitly if the FILE is not already in write mode.
Diffstat (limited to 'src')
-rw-r--r--src/stdio/vfprintf.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c
index af069d1..2100eb5 100644
--- a/src/stdio/vfprintf.c
+++ b/src/stdio/vfprintf.c
@@ -678,7 +678,8 @@ int vfprintf(FILE *restrict f, const char *restrict fmt, va_list ap)
f->buf_size = sizeof internal_buf;
f->wpos = f->wbase = f->wend = 0;
}
- ret = printf_core(f, fmt, &ap2, nl_arg, nl_type);
+ if (!f->wend && __towrite(f)) ret = -1;
+ else ret = printf_core(f, fmt, &ap2, nl_arg, nl_type);
if (saved_buf) {
f->write(f, 0, 0);
if (!f->wpos) ret = -1;