aboutsummaryrefslogtreecommitdiff
path: root/lib/dirtree.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2014-07-21 19:55:06 -0500
committerRob Landley <rob@landley.net>2014-07-21 19:55:06 -0500
commit280bb5942526c06211185144a5cdb4c5d05aa2f6 (patch)
treefbcb3899e2c9bc59f03dda0cf5bcaa2fe24a9cb0 /lib/dirtree.c
parent31db579265fa9e0acea036faa486be26f508e67a (diff)
downloadtoybox-280bb5942526c06211185144a5cdb4c5d05aa2f6.tar.gz
Fix memory leak in error path.
Diffstat (limited to 'lib/dirtree.c')
-rw-r--r--lib/dirtree.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/dirtree.c b/lib/dirtree.c
index 361686aa..85b1a3cf 100644
--- a/lib/dirtree.c
+++ b/lib/dirtree.c
@@ -60,7 +60,9 @@ struct dirtree *dirtree_add_node(struct dirtree *parent, char *name,
error:
if (notdotdot(name)) {
char *path = parent ? dirtree_path(parent, 0) : "";
- perror_msg("%s%s%s",path, parent ? "/" : "", name);
+
+ perror_msg("%s%s%s", path, parent ? "/" : "", name);
+ if (parent) free(path);
}
if (parent) parent->symlink = (char *)1;
free(dt);