diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/dirtree.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/dirtree.c b/lib/dirtree.c index 70b567d2..cc5d0545 100644 --- a/lib/dirtree.c +++ b/lib/dirtree.c @@ -52,14 +52,13 @@ struct dirtree *dirtree_add_node(struct dirtree *parent, char *name, int flags) } // Allocate/populate return structure - dt = xmalloc((len = sizeof(struct dirtree)+len+1)+linklen); - memset(dt, 0, statless ? sizeof(struct dirtree)+1 - : offsetof(struct dirtree, st)); + memset(dt = xmalloc((len = sizeof(struct dirtree)+len+1)+linklen), 0, + statless ? sizeof(struct dirtree)+1 : offsetof(struct dirtree, st)); dt->parent = parent; dt->again = statless ? 2 : 0; if (!statless) memcpy(&dt->st, &st, sizeof(struct stat)); if (name) strcpy(dt->name, name); - else dt->st.st_mode = S_IFDIR; + else *dt->name = 0, dt->st.st_mode = S_IFDIR; if (linklen) dt->symlink = memcpy(len+(char *)dt, libbuf, linklen); return dt; |