musl - musl - an implementation of the standard library for Linux-based systems

index : musl
musl - an implementation of the standard library for Linux-based systems
summary refs log tree commit diff
path: root/src/stdio/vswprintf.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2023年03月22日 12:56:46 -0400
committerRich Felker <dalias@aerifal.cx>2023年03月22日 12:56:46 -0400
commit1d5750b95c06913a1f18a995481276d698d20fae (patch)
treea64fe442a196ad0d6cfa6c61d330b85507361f90 /src/stdio/vswprintf.c
parent0e5234807dcdc76c43f9313c6ba9e2b7da408d8c (diff)
downloadmusl-1d5750b95c06913a1f18a995481276d698d20fae.tar.gz
fix swprintf handling of nul character in output
the buffer-flush function did not account for mbtowc returning 0 rather than 1 when converting the nul character. this prevented advancing past it, instead repeatedly converting it into the output wide character string until the max output length was exhausted.
Diffstat (limited to 'src/stdio/vswprintf.c')
-rw-r--r--src/stdio/vswprintf.c 1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/stdio/vswprintf.c b/src/stdio/vswprintf.c
index 7f98c5c9..fc223cf2 100644
--- a/src/stdio/vswprintf.c
+++ b/src/stdio/vswprintf.c
@@ -18,6 +18,7 @@ static size_t sw_write(FILE *f, const unsigned char *s, size_t l)
if (s!=f->wbase && sw_write(f, f->wbase, f->wpos-f->wbase)==-1)
return -1;
while (c->l && l && (i=mbtowc(c->ws, (void *)s, l))>=0) {
+ if (!i) i=1;
s+=i;
l-=i;
c->l--;
generated by cgit v1.2.1 (git 2.18.0) at 2025年09月08日 17:19:50 +0000

AltStyle によって変換されたページ (->オリジナル) /