diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/stdio/vswprintf.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/stdio/vswprintf.c b/src/stdio/vswprintf.c index 7d237bae..6eb2f6ac 100644 --- a/src/stdio/vswprintf.c +++ b/src/stdio/vswprintf.c @@ -24,7 +24,14 @@ static size_t sw_write(FILE *f, const unsigned char *s, size_t l) c->ws++; } *c->ws = 0; - return i<0 ? i : l0; + if (i < 0) { + f->wpos = f->wbase = f->wend = 0; + f->flags |= F_ERR; + return i; + } + f->wend = f->buf + f->buf_size; + f->wpos = f->wbase = f->buf; + return l0; } int vswprintf(wchar_t *restrict s, size_t n, const wchar_t *restrict fmt, va_list ap) |