sbase

suckless unix tools
git clone git://git.suckless.org/sbase
Log | Files | Refs | README | LICENSE

commit d4634f6740015fc630cca483ce38d6d0b58930b1
parent 57c9cab8496efa6088998fc84d45a7340ed215fa
Author: Michael Forney <mforney@mforney.org>
Date:   Tue, 31 Dec 2019 13:39:08 -0800

libutil/getlines: Use reallocarray

Diffstat:
Mlibutil/getlines.c | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 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);