summaryrefslogtreecommitdiffstats
path: root/bftw.c
diff options
context:
space:
mode:
Diffstat (limited to 'bftw.c')
-rw-r--r--bftw.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/bftw.c b/bftw.c
index 1eac4bc..46bcede 100644
--- a/bftw.c
+++ b/bftw.c
@@ -207,7 +207,7 @@ static void dircache_pop(struct dircache *cache, struct dircache_entry *entry) {
/** Add an entry to the dircache. */
static struct dircache_entry *dircache_add(struct dircache *cache, struct dircache_entry *parent, const char *name) {
size_t namelen = strlen(name);
- size_t size = sizeof(struct dircache_entry) + namelen;
+ size_t size = sizeof(struct dircache_entry) + namelen + 1;
bool needs_slash = false;
if (namelen == 0 || name[namelen - 1] != '/') {
@@ -241,6 +241,7 @@ static struct dircache_entry *dircache_add(struct dircache *cache, struct dircac
if (needs_slash) {
entry->name[namelen++] = '/';
}
+ entry->name[namelen] = '\0';
entry->namelen = namelen;
return entry;