From 91f18ef9289c9e48c35ee5df3340022ceab54149 Mon Sep 17 00:00:00 2001 From: "Tim J. Robbins" Date: Fri, 6 Aug 2004 17:00:09 +0000 Subject: [PATCH] Fix an off-by-one bug that caused the first character of the buffer to be uninitialized. --- lib/libc/stdio/fgetwln.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/libc/stdio/fgetwln.c b/lib/libc/stdio/fgetwln.c index a55932172fa..1a1ad2ddeaa 100644 --- a/lib/libc/stdio/fgetwln.c +++ b/lib/libc/stdio/fgetwln.c @@ -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; }