fix scanf %c conversion wrongly storing a terminating null byte

this seems to have been a regression from the refactoring which added
the 'm' modifier.
This commit is contained in:
Rich Felker 2013-06-22 17:23:45 -04:00
parent c20804500d
commit ef5507867b
2 changed files with 8 additions and 4 deletions

View File

@ -265,8 +265,10 @@ int vfscanf(FILE *restrict f, const char *restrict fmt, va_list ap)
if (size == SIZE_l) *(wchar_t **)dest = wcs;
else *(char **)dest = s;
}
if (wcs) wcs[i] = 0;
if (s) s[i] = 0;
if (t != 'c') {
if (wcs) wcs[i] = 0;
if (s) s[i] = 0;
}
break;
case 'p':
case 'X':

View File

@ -281,8 +281,10 @@ int vfwscanf(FILE *restrict f, const wchar_t *restrict fmt, va_list ap)
if (size == SIZE_l) *(wchar_t **)dest = wcs;
else *(char **)dest = s;
}
if (wcs) wcs[i] = 0;
if (s) s[i] = 0;
if (t != 'c') {
if (wcs) wcs[i] = 0;
if (s) s[i] = 0;
}
break;
case 'd': case 'i': case 'o': case 'u': case 'x':