diff options
author | Liu Xue <liuxueliu.liu@huawei.com> | 2015-12-14 11:31:28 +0000 |
---|---|---|
committer | Greg Wallace <greg@gregtwallace.com> | 2016-01-19 22:02:20 -0500 |
commit | d17426964639cb440256dd70a1e3cdf36eebf019 (patch) | |
tree | d9b8d9312442f38fe05be43c1e6bf71d7c5d24ca | |
parent | a144fc1694978ffb871fc9bd5bcd713e44aba7e3 (diff) | |
download | android_external_f2fs-tools-d17426964639cb440256dd70a1e3cdf36eebf019.tar.gz android_external_f2fs-tools-d17426964639cb440256dd70a1e3cdf36eebf019.tar.bz2 android_external_f2fs-tools-d17426964639cb440256dd70a1e3cdf36eebf019.zip |
fsck.f2fs: deal with realloc size and realloc failure
Deal with realloc failure to avoid memory leak and memory free,
and assert realloc size to avoid double free for tree_mark.
Change-Id: I39fef4d4d03eeb8334f5d4899701a2d1a3852588
Signed-off-by: Xue Liu <liuxueliu.liu@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r-- | fsck/fsck.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/fsck/fsck.c b/fsck/fsck.c index 63ee914..58786f2 100644 --- a/fsck/fsck.c +++ b/fsck/fsck.c @@ -892,7 +892,9 @@ static void print_dentry(__u32 depth, __u8 *name, if (tree_mark_size <= depth) { tree_mark_size *= 2; + ASSERT(tree_mark_size != 0); tree_mark = realloc(tree_mark, tree_mark_size); + ASSERT(tree_mark != NULL); } if (last_de) @@ -1256,6 +1258,7 @@ void fsck_init(struct f2fs_sb_info *sbi) build_sit_area_bitmap(sbi); + ASSERT(tree_mark_size != 0); tree_mark = calloc(tree_mark_size, 1); ASSERT(tree_mark != NULL); } |