Fix off-by-one error when pushing back a multibyte sequence in

wide character class (%l[) and wide string (%ls) conversions.
This commit is contained in:
Tim J. Robbins 2002-10-17 13:04:00 +00:00
parent 44f219ea75
commit 0145ba86d1

View File

@ -464,9 +464,11 @@ again: c = *fmt++;
if (nconv != (size_t)-2) {
if (wctob(*wcp) != EOF &&
!ccltab[wctob(*wcp)]) {
while (--n > 0)
while (n != 0) {
n--;
__ungetc(buf[n],
fp);
}
break;
}
nread += n;
@ -562,9 +564,11 @@ again: c = *fmt++;
*wcp = L'\0';
if (nconv != (size_t)-2) {
if (iswspace(*wcp)) {
while (--n > 0)
while (n != 0) {
n--;
__ungetc(buf[n],
fp);
}
break;
}
nread += n;