diff options
author | Byongho Lee <bhlee.kernel@gmail.com> | 2015-08-21 17:51:52 +0900 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2015-08-31 19:25:12 +0200 |
commit | ae60507e59a1cad43303a0f9e1b72ef4e5bb1e72 (patch) | |
tree | 180a89c224d665244ca3c9b1da680203b2c62d5d /btrfs-list.c | |
parent | d7748770a78a4a44f39f4f0e629885a255d24d90 (diff) | |
download | btrfs-progs-ae60507e59a1cad43303a0f9e1b72ef4e5bb1e72.tar.gz |
btrfs-progs: fix memory leaks in error path
This patch includes below fixes in error path:
1. fix memory leaks if realloc() fails
2. add missing call free_history() before return error in scrub_read_file()
Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com>
Reviewed-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'btrfs-list.c')
-rw-r--r-- | btrfs-list.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/btrfs-list.c b/btrfs-list.c index 875a89d..d54de61 100644 --- a/btrfs-list.c +++ b/btrfs-list.c @@ -254,11 +254,15 @@ static int btrfs_list_setup_comparer(struct btrfs_list_comparer_set **comp_set, BUG_ON(set->ncomps > set->total); if (set->ncomps == set->total) { + void *tmp; + size = set->total + BTRFS_LIST_NCOMPS_INCREASE; size = sizeof(*set) + size * sizeof(struct btrfs_list_comparer); + tmp = set; set = realloc(set, size); if (!set) { fprintf(stderr, "memory allocation failed\n"); + free(tmp); exit(1); } @@ -1232,11 +1236,15 @@ int btrfs_list_setup_filter(struct btrfs_list_filter_set **filter_set, BUG_ON(set->nfilters > set->total); if (set->nfilters == set->total) { + void *tmp; + size = set->total + BTRFS_LIST_NFILTERS_INCREASE; size = sizeof(*set) + size * sizeof(struct btrfs_list_filter); + tmp = set; set = realloc(set, size); if (!set) { fprintf(stderr, "memory allocation failed\n"); + free(tmp); exit(1); } |