Btrfs-progs: fix a small memory leak in btrfs-list.c

valgrind found this very obvious issue.

Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
This commit is contained in:
Stefan Behrens 2013-04-09 19:08:32 +02:00 committed by David Sterba
parent 75c47053a4
commit a3ed81c5e9
1 changed files with 6 additions and 6 deletions

View File

@ -577,13 +577,13 @@ static int resolve_root(struct root_lookup *rl, struct root_info *ri,
add_len = strlen(found->path);
/* room for / and for null */
tmp = malloc(add_len + 2 + len);
if (!tmp) {
perror("malloc failed");
exit(1);
}
if (full_path) {
/* room for / and for null */
tmp = malloc(add_len + 2 + len);
if (!tmp) {
perror("malloc failed");
exit(1);
}
memcpy(tmp + add_len + 1, full_path, len);
tmp[add_len] = '/';
memcpy(tmp, found->path, add_len);