summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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