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:27:29 +01:00
parent ea1cdaf262
commit 0e636bf51a

View file

@ -206,7 +206,7 @@ int bind_mount_parse(CustomMount **l, size_t *n, const char *s, bool read_only)
}
if (isempty(source))
source = NULL;
source = mfree(source);
else if (!source_path_is_valid(source))
return -EINVAL;
@ -219,12 +219,10 @@ int bind_mount_parse(CustomMount **l, size_t *n, const char *s, bool read_only)
if (!m)
return -ENOMEM;
m->source = source;
m->destination = destination;
m->source = TAKE_PTR(source);
m->destination = TAKE_PTR(destination);
m->read_only = read_only;
m->options = opts;
source = destination = opts = NULL;
m->options = TAKE_PTR(opts);
return 0;
}