summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>2016-09-05 06:10:51 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>2016-09-05 06:10:51 +0000
commit0b51c11a0e75197a8791f6e635a08e36d5a42bd5 (patch)
tree39559df5b723a1e63df301febf1be59b214fd09d
parent0bbb7d483b1575e804051464890061cfa048f0cc (diff)
Notes
-rw-r--r--lib/libc/stdio/fgetws.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/libc/stdio/fgetws.c b/lib/libc/stdio/fgetws.c
index efff8385b3e3..8513a372835b 100644
--- a/lib/libc/stdio/fgetws.c
+++ b/lib/libc/stdio/fgetws.c
@@ -62,10 +62,14 @@ fgetws_l(wchar_t * __restrict ws, int n, FILE * __restrict fp, locale_t locale)
goto error;
}
+ wsp = ws;
+ if (n == 1)
+ goto ok;
+
if (fp->_r <= 0 && __srefill(fp))
/* EOF or ferror */
goto error;
- wsp = ws;
+
sret = 0;
do {
src = fp->_p;
@@ -107,9 +111,9 @@ fgetws_l(wchar_t * __restrict ws, int n, FILE * __restrict fp, locale_t locale)
if (wsp == ws)
/* EOF */
goto error;
+ok:
*wsp = L'\0';
FUNLOCKFILE(fp);
-
return (ws);
error: