From 668d59a23068fc4a8aa806b914d95c71e903e92f Mon Sep 17 00:00:00 2001 From: kib Date: Thu, 13 Jul 2017 09:27:11 +0000 Subject: MFC r320472,r320508,r320509: Make stdio deferred cancel-safe. --- lib/libc/stdio/getdelim.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'lib/libc/stdio/getdelim.c') diff --git a/lib/libc/stdio/getdelim.c b/lib/libc/stdio/getdelim.c index 7e0b2e2..26c608f 100644 --- a/lib/libc/stdio/getdelim.c +++ b/lib/libc/stdio/getdelim.c @@ -112,7 +112,7 @@ getdelim(char ** __restrict linep, size_t * __restrict linecapp, int delim, u_char *endp; size_t linelen; - FLOCKFILE(fp); + FLOCKFILE_CANCELSAFE(fp); ORIENT(fp, -1); if (linep == NULL || linecapp == NULL) { @@ -127,9 +127,9 @@ getdelim(char ** __restrict linep, size_t * __restrict linecapp, int delim, /* If fp is at EOF already, we just need space for the NUL. */ if (!__sfeof(fp) || expandtofit(linep, 1, linecapp)) goto error; - FUNLOCKFILE(fp); (*linep)[0] = '\0'; - return (-1); + linelen = -1; + goto end; } linelen = 0; @@ -150,11 +150,12 @@ getdelim(char ** __restrict linep, size_t * __restrict linecapp, int delim, done: /* Invariant: *linep has space for at least linelen+1 bytes. */ (*linep)[linelen] = '\0'; - FUNLOCKFILE(fp); +end: + FUNLOCKFILE_CANCELSAFE(); return (linelen); error: fp->_flags |= __SERR; - FUNLOCKFILE(fp); - return (-1); + linelen = -1; + goto end; } -- cgit v1.1