summaryrefslogtreecommitdiff
path: root/cmds-fi-disk_usage.c
diff options
context:
space:
mode:
authorRakesh Pandit <rakesh@tuxera.com>2014-04-19 14:12:03 +0300
committerDavid Sterba <dsterba@suse.cz>2014-12-04 16:48:10 +0100
commit0c1f1b2ae88ec61234e5e8cf87d92434ee947998 (patch)
tree175e0f3c09f2481da577842b844883fef7dbfb52 /cmds-fi-disk_usage.c
parent7c7fd19b8d8f909d1153aa5abc2bb542d4cfd6ae (diff)
Btrfs-progs: fi usage: free memory if realloc fails
Lets not assign *info_ptr to 0 before calling free on it and lose track of already allocated memory if realloc fails in add_info_to_list. Lets call free first. Signed-off-by: Rakesh Pandit <rakesh@tuxera.com> Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'cmds-fi-disk_usage.c')
-rw-r--r--cmds-fi-disk_usage.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
index 736294ee..9fd59bc1 100644
--- a/cmds-fi-disk_usage.c
+++ b/cmds-fi-disk_usage.c
@@ -104,6 +104,7 @@ static int add_info_to_list(struct chunk_info **info_ptr,
struct chunk_info *res = realloc(*info_ptr, size);
if (!res) {
+ free(*info_ptr);
fprintf(stderr, "ERROR: not enough memory\n");
return -1;
}
@@ -224,7 +225,6 @@ static int load_chunk_info(int fd,
if (add_info_to_list(info_ptr, info_count, item)) {
*info_ptr = 0;
- free(*info_ptr);
return -100;
}