On Sat, Nov 18, 2017 at 05:51:48PM +0100, Szabolcs Nagy wrote: > Update the buffer position according to the bytes consumed into st when > decoding an incomplete character at the end of the buffer. > --- > src/stdio/fgetwc.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/src/stdio/fgetwc.c b/src/stdio/fgetwc.c > index e455cfec..a00c1a86 100644 > --- a/src/stdio/fgetwc.c > +++ b/src/stdio/fgetwc.c > @@ -15,20 +15,21 @@ static wint_t __fgetwc_unlocked_internal(FILE *f) > if (f->rpos < f->rend) { > l = mbrtowc(&wc, (void *)f->rpos, f->rend - f->rpos, &st); > if (l+2 >= 2) { > f->rpos += l + !l; /* l==0 means 1 byte, null */ > return wc; > } > if (l == -1) { > f->rpos++; > return WEOF; > } > + f->rpos = f->rend; > } else l = -2; Thanks, applying! Here is a test case that demonstrates the bug reproducibly; feel free to adapt (it should probably use the framework functions for getting a utf-8 locale and error reporting) & include it in libc-test. Rich