libutil/getlines: Use reallocarray

This commit is contained in:
Michael Forney 2019-12-31 13:39:08 -08:00
parent 57c9cab849
commit d4634f6740
1 changed files with 1 additions and 1 deletions

View File

@ -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);