summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2004-08-06 17:00:09 +0000
committertjr <tjr@FreeBSD.org>2004-08-06 17:00:09 +0000
commitea9862ff9f2c8999d78118af4466bbeff34988de (patch)
tree94bed82daa80b06b78e1ee71d9f301f3d0a2055a /lib/libc/stdio
parentf6cdeb816b03da9e8ef0a2a85779ceb704457f43 (diff)
downloadFreeBSD-src-ea9862ff9f2c8999d78118af4466bbeff34988de.zip
FreeBSD-src-ea9862ff9f2c8999d78118af4466bbeff34988de.tar.gz
Fix an off-by-one bug that caused the first character of the buffer to
be uninitialized.
Diffstat (limited to 'lib/libc/stdio')
-rw-r--r--lib/libc/stdio/fgetwln.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/lib/libc/stdio/fgetwln.c b/lib/libc/stdio/fgetwln.c
index a559321..1a1ad2d 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;
}
OpenPOWER on IntegriCloud