diff options
author | Jakob Kaivo <jkk@ung.org> | 2020-01-14 15:57:52 -0500 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2020-01-14 15:57:52 -0500 |
commit | 617dcf1b42fced747fe33ed0756362f827dd4149 (patch) | |
tree | 88d91e82e74102f7975ee9a831e3d091119d2941 | |
parent | ef68a24f9dbb9ea7d29d8c3ef483b136f49c6cb0 (diff) |
use calloc() to ensure NUL termination, remember to NULL terminate the array
-rw-r--r-- | sources.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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++; } |