summaryrefslogtreecommitdiff
path: root/cmds-send.c
diff options
context:
space:
mode:
authorByongho Lee <bhlee.kernel@gmail.com>2015-08-21 17:51:52 +0900
committerDavid Sterba <dsterba@suse.com>2015-08-31 19:25:12 +0200
commitae60507e59a1cad43303a0f9e1b72ef4e5bb1e72 (patch)
tree180a89c224d665244ca3c9b1da680203b2c62d5d /cmds-send.c
parentd7748770a78a4a44f39f4f0e629885a255d24d90 (diff)
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 'cmds-send.c')
-rw-r--r--cmds-send.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/cmds-send.c b/cmds-send.c
index a0b7f95f..95fd4aaa 100644
--- a/cmds-send.c
+++ b/cmds-send.c
@@ -174,11 +174,16 @@ out:
static int add_clone_source(struct btrfs_send *s, u64 root_id)
{
+ void *tmp;
+
+ tmp = s->clone_sources;
s->clone_sources = realloc(s->clone_sources,
sizeof(*s->clone_sources) * (s->clone_sources_count + 1));
- if (!s->clone_sources)
+ if (!s->clone_sources) {
+ free(tmp);
return -ENOMEM;
+ }
s->clone_sources[s->clone_sources_count++] = root_id;
return 0;