commit d4634f6740015fc630cca483ce38d6d0b58930b1
Author: Michael Forney <[email protected]>
AuthorDate: Tue Dec 31 13:39:08 2019 -0800
Commit: Michael Forney <[email protected]>
CommitDate: Tue Dec 31 13:39:08 2019 -0800
libutil/getlines: Use reallocarray
diff --git a/libutil/getlines.c b/libutil/getlines.c
index b912769..cef9a61 100644
--- a/libutil/getlines.c
+++ b/libutil/getlines.c
@@ -16,7 +16,7 @@ getlines(FILE *fp, struct linebuf *b)
while ((len = getline(&line, &size, fp)) > 0) {
if (++b->nlines > b->capacity) {
b->capacity += 512;
- b->lines = erealloc(b->lines, b->capacity *
sizeof(*b->lines));
+ b->lines = ereallocarray(b->lines, b->capacity,
sizeof(*b->lines));
}
linelen = len;
b->lines[b->nlines - 1].data = memcpy(emalloc(linelen + 1),
line, linelen + 1);