aboutsummaryrefslogtreecommitdiff
path: root/lib/compat
diff options
context:
space:
mode:
Diffstat (limited to 'lib/compat')
-rw-r--r--lib/compat/getline.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/compat/getline.c b/lib/compat/getline.c
index f330c6d..e63c50e 100644
--- a/lib/compat/getline.c
+++ b/lib/compat/getline.c
@@ -43,6 +43,16 @@ ssize_t getline(char **line, size_t *n, FILE *fp)
buffer[len++] = c;
} while (c != '\n');
+ if (len == cap) {
+ new = realloc(buffer, cap ? cap * 2 : 32);
+ if (new == NULL)
+ return -1;
+
+ buffer = new;
+ }
+
+ buffer[len] = '\0';
+
*line = buffer;
*n = len;
return len;