btrfs-progs: mkfs/rootdir: Fix memory leak in traverse_directory()
authorQu Wenruo <wqu@suse.com>
Wed, 14 Feb 2018 07:50:06 +0000 (15:50 +0800)
committerDavid Sterba <dsterba@suse.com>
Wed, 14 Feb 2018 15:31:19 +0000 (16:31 +0100)
commit78c5a90ebf22989b07770de6324cc14a70d72a17
tree8e2c7b6535cd982734078c7f82f14819d2f05f5c
parent54246115ba343d07651eff05e8bf7d159a897670
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>
mkfs/rootdir.c
mkfs/rootdir.h