diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-03-11 14:27:29 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-03-11 14:29:30 +0100 |
commit | 0e636bf51aaaf319695f9d0dc91a29b03c8bd69b (patch) | |
tree | 7096df22b2e62c753cb6faec2fa9d31e303786e6 | |
parent | fuzz: add a memleak reproducer for fuzz-nspawn-settings (diff) | |
download | systemd-0e636bf51aaaf319695f9d0dc91a29b03c8bd69b.tar.xz systemd-0e636bf51aaaf319695f9d0dc91a29b03c8bd69b.zip |
nspawn: fix memleak uncovered by fuzzer
Also use TAKE_PTR as appropriate.
-rw-r--r-- | src/nspawn/nspawn-mount.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/nspawn/nspawn-mount.c b/src/nspawn/nspawn-mount.c index eb0a26ef35..13f50b2d37 100644 --- a/src/nspawn/nspawn-mount.c +++ b/src/nspawn/nspawn-mount.c @@ -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; } |