Fix an off-by-one bug that caused the first character of the buffer to

be uninitialized.
This commit is contained in:
Tim J. Robbins 2004-08-06 17:00:09 +00:00
parent ddabcdb433
commit 91f18ef928

View File

@ -46,11 +46,10 @@ fgetwln(FILE * __restrict fp, size_t *lenp)
len = 0;
while ((wc = __fgetwc(fp)) != WEOF) {
#define GROW 512
len++;
if (len * sizeof(wchar_t) >= fp->_lb._size &&
__slbexpand(fp, (len + GROW) * sizeof(wchar_t)))
goto error;
*((wchar_t *)fp->_lb._base + len) = wc;
*((wchar_t *)fp->_lb._base + len++) = wc;
if (wc == L'\n')
break;
}