nspawn: fix memleak uncovered by fuzzer

Also use TAKE_PTR as appropriate.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2019-03-11 14:29:30 +01:00
parent ea1cdaf262
commit 0e636bf51a
+4 -6
View File
@@ -206,7 +206,7 @@ int bind_mount_parse(CustomMount **l, size_t *n, const char *s, bool read_only)
} }
if (isempty(source)) if (isempty(source))
source = NULL; source = mfree(source);
else if (!source_path_is_valid(source)) else if (!source_path_is_valid(source))
return -EINVAL; return -EINVAL;
@@ -219,12 +219,10 @@ int bind_mount_parse(CustomMount **l, size_t *n, const char *s, bool read_only)
if (!m) if (!m)
return -ENOMEM; return -ENOMEM;
m->source = source; m->source = TAKE_PTR(source);
m->destination = destination; m->destination = TAKE_PTR(destination);
m->read_only = read_only; m->read_only = read_only;
m->options = opts; m->options = TAKE_PTR(opts);
source = destination = opts = NULL;
return 0; return 0;
} }