summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2020-01-14 15:57:52 -0500
committerJakob Kaivo <jkk@ung.org>2020-01-14 15:57:52 -0500
commit617dcf1b42fced747fe33ed0756362f827dd4149 (patch)
tree88d91e82e74102f7975ee9a831e3d091119d2941
parentef68a24f9dbb9ea7d29d8c3ef483b136f49c6cb0 (diff)
use calloc() to ensure NUL termination, remember to NULL terminate the array
-rw-r--r--sources.c6
1 files changed, 4 insertions, 2 deletions
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++;
}