summaryrefslogtreecommitdiff
path: root/mkfs/rootdir.h
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2018-02-14 15:50:06 +0800
committerDavid Sterba <dsterba@suse.com>2018-02-14 16:31:19 +0100
commit78c5a90ebf22989b07770de6324cc14a70d72a17 (patch)
tree8e2c7b6535cd982734078c7f82f14819d2f05f5c /mkfs/rootdir.h
parent54246115ba343d07651eff05e8bf7d159a897670 (diff)
btrfs-progs: mkfs/rootdir: Fix memory leak in traverse_directory()
The bug is exposed by mkfs test case 009, with D=asan. We are leaking memory of parent_dir_entry->path() which ,except the rootdir, is allocated by strdup(). Before fixing it, unifiy the allocation of parent_dir_entry() to heap allocation. Then fix it by adding "free(parent_dir_entry->path);" in traverse_directory() and error handler. Issue: #92 Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'mkfs/rootdir.h')
-rw-r--r--mkfs/rootdir.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/mkfs/rootdir.h b/mkfs/rootdir.h
index d0fc2eb5..f06c7dd1 100644
--- a/mkfs/rootdir.h
+++ b/mkfs/rootdir.h
@@ -23,7 +23,7 @@
struct directory_name_entry {
const char *dir_name;
- const char *path;
+ char *path;
ino_t inum;
struct list_head list;
};