summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2015-03-07 14:19:20 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2015-03-07 14:19:20 -0500
commit8a16a7b4e7f6702a7e6edaead80ecf04be7d3ba2 (patch)
tree298307ad078652c09e9d789a38d690e3b8732b56 /src
parent5eed9d0d85be0767fe6a4d19c7abacb1f09e4b75 (diff)
nspawn: fix use-after-free and leak in error paths
CID #1257765.
Diffstat (limited to 'src')
-rw-r--r--src/nspawn/nspawn.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index 8833704ab7..c851fdd136 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -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;