diff options
| author | David Schultz <das@FreeBSD.org> | 2009-04-06 13:50:04 +0000 |
|---|---|---|
| committer | David Schultz <das@FreeBSD.org> | 2009-04-06 13:50:04 +0000 |
| commit | 6685ac34d91d361a03918777934cf037bedd8841 (patch) | |
| tree | 55b9d467c4c819ca6310500170877ae242edc70b /lib/libc/stdio/getdelim.c | |
| parent | ecac0338c16295ef854e41935920aacf5af8d867 (diff) | |
Notes
Diffstat (limited to 'lib/libc/stdio/getdelim.c')
| -rw-r--r-- | lib/libc/stdio/getdelim.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libc/stdio/getdelim.c b/lib/libc/stdio/getdelim.c index fb028899a28d..7af154f6af51 100644 --- a/lib/libc/stdio/getdelim.c +++ b/lib/libc/stdio/getdelim.c @@ -120,7 +120,6 @@ getdelim(char ** __restrict linep, size_t * __restrict linecapp, int delim, goto error; } - linelen = 0; if (*linecapp == 0) *linep = NULL; @@ -128,9 +127,12 @@ getdelim(char ** __restrict linep, size_t * __restrict linecapp, int delim, /* If fp is at EOF already, we just need space for the NUL. */ if (__sferror(fp) || expandtofit(linep, 1, linecapp)) goto error; - goto done; + FUNLOCKFILE(fp); + (*linep)[0] = '\0'; + return (-1); } + linelen = 0; while ((endp = memchr(fp->_p, delim, fp->_r)) == NULL) { if (sappend(linep, &linelen, linecapp, fp->_p, fp->_r)) goto error; |
