From 536c6d5a4205e2a3f161f2983ce1e0ac3082187d Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Sat, 13 Jun 2015 05:17:16 +0000 Subject: fix idiom for setting stdio stream orientation to wide the old idiom, f->mode |= f->mode+1, was adapted from the idiom for setting byte orientation, f->mode |= f->mode-1, but the adaptation was incorrect. unless the stream was alreasdy set byte-oriented, this code incremented f->mode each time it was executed, which would eventually lead to overflow. it could be fixed by changing it to f->mode |= 1, but upcoming changes will require slightly more work at the time of wide orientation, so it makes sense to just call fwide. as an optimization in the single-character functions, fwide is only called if the stream is not already wide-oriented. --- src/stdio/vfwprintf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/stdio/vfwprintf.c') diff --git a/src/stdio/vfwprintf.c b/src/stdio/vfwprintf.c index deff9828..f06d5aed 100644 --- a/src/stdio/vfwprintf.c +++ b/src/stdio/vfwprintf.c @@ -359,7 +359,7 @@ int vfwprintf(FILE *restrict f, const wchar_t *restrict fmt, va_list ap) } FLOCK(f); - f->mode |= f->mode+1; + fwide(f, 1); olderr = f->flags & F_ERR; f->flags &= ~F_ERR; ret = wprintf_core(f, fmt, &ap2, nl_arg, nl_type); -- cgit v1.2.1