nspawn: fix use-after-free and leak in error paths

CID #1257765.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2015-03-07 14:19:20 -05:00
parent 5eed9d0d85
commit 8a16a7b4e7

View file

@ -3735,7 +3735,7 @@ int main(int argc, char *argv[]) {
}
if (arg_ephemeral) {
char *np;
_cleanup_free_ char *np = NULL;
/* If the specified path is a mount point we
* generate the new snapshot immediately
@ -3765,13 +3765,13 @@ int main(int argc, char *argv[]) {
r = btrfs_subvol_snapshot(arg_directory, np, arg_read_only, true);
if (r < 0) {
free(np);
log_error_errno(r, "Failed to create snapshot %s from %s: %m", np, arg_directory);
goto finish;
}
free(arg_directory);
arg_directory = np;
np = NULL;
remove_subvol = true;