aboutsummaryrefslogtreecommitdiffstats
path: root/cmds-receive.c
diff options
context:
space:
mode:
authorNeil Horman <nhorman@tuxdriver.com>2015-12-03 13:45:44 -0500
committerDavid Sterba <dsterba@suse.com>2016-01-12 15:01:06 +0100
commit2cb9b4dbbd21585253a3dc314e91418ff3a9bb68 (patch)
tree8fa8a268d545893d6ed82b3dae1677249276ab71 /cmds-receive.c
parente3bd2d145f3821e5c57d56931e78efca22578a97 (diff)
downloadbtrfs-progs-2cb9b4dbbd21585253a3dc314e91418ff3a9bb68.tar.gz
btrfs-progs-2cb9b4dbbd21585253a3dc314e91418ff3a9bb68.tar.xz
btrfs-progs-2cb9b4dbbd21585253a3dc314e91418ff3a9bb68.zip
btrfs: only free root_path if it was allocated from the heap
Noticed this while doing some snapshots in a chroot environment btrfs receive can set root_path to either realmnt, which is passed in from the command line, or to a heap allocated via find_mount_root in do_receive. We should only free the later, not the former, as the former results in an invalid pointer warning from glibc during free. Signed-off-by: Neil Horman <nhorman@tuxdriver.com> CC: Josef Bacik <jbacik@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'cmds-receive.c')
-rw-r--r--cmds-receive.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/cmds-receive.c b/cmds-receive.c
index 3a84a3b..c25dc59 100644
--- a/cmds-receive.c
+++ b/cmds-receive.c
@@ -1201,7 +1201,9 @@ out:
close(r->write_fd);
r->write_fd = -1;
}
- free(r->root_path);
+
+ if (r->root_path != realmnt)
+ free(r->root_path);
r->root_path = NULL;
r->dest_dir_path = NULL;
free(dest_dir_full_path);