From 617dcf1b42fced747fe33ed0756362f827dd4149 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Tue, 14 Jan 2020 15:57:52 -0500 Subject: use calloc() to ensure NUL termination, remember to NULL terminate the array --- sources.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sources.c') diff --git a/sources.c b/sources.c index 0963bc9..f12eebe 100644 --- a/sources.c +++ b/sources.c @@ -23,11 +23,13 @@ static int addfile(const char *path, const struct stat *st, int flags, struct FT } filelist = tmp; - filelist[nfiles] = malloc(sizeof(*filelist[nfiles]) + strlen(path) + 1); + filelist[nfiles] = calloc(1, sizeof(*filelist[nfiles]) + strlen(path) + 1); filelist[nfiles]->st = *st; strcpy(filelist[nfiles]->path, strdup(path)); - //filelist[nfiles + 1] = NULL; + + filelist[nfiles + 1] = NULL; + nfiles++; } -- cgit v1.2.1