aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc/stdio/getdelim.c
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/stdio/getdelim.c')
-rw-r--r--newlib/libc/stdio/getdelim.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/newlib/libc/stdio/getdelim.c b/newlib/libc/stdio/getdelim.c
index 8ec9d40..64f60ee 100644
--- a/newlib/libc/stdio/getdelim.c
+++ b/newlib/libc/stdio/getdelim.c
@@ -109,21 +109,24 @@ __getdelim (bufptr, n, delim, fp)
}
}
- /* Buffer is too small so reallocate a larger buffer. */
- pos = ptr - buf;
- newsize = (*n << 1);
- buf = realloc (buf, newsize);
- if (buf == NULL)
+ if (cont)
{
- cont = 0;
- break;
- }
+ /* Buffer is too small so reallocate a larger buffer. */
+ pos = ptr - buf;
+ newsize = (*n << 1);
+ buf = realloc (buf, newsize);
+ if (buf == NULL)
+ {
+ cont = 0;
+ break;
+ }
- /* After reallocating, continue in new buffer */
- *bufptr = buf;
- *n = newsize;
- ptr = buf + pos;
- numbytes = newsize - pos;
+ /* After reallocating, continue in new buffer */
+ *bufptr = buf;
+ *n = newsize;
+ ptr = buf + pos;
+ numbytes = newsize - pos;
+ }
}
_funlockfile (fp);