From: Zbigniew Jędrzejewski-Szmek Date: Mon, 11 Mar 2019 13:27:29 +0000 (+0100) Subject: nspawn: fix memleak uncovered by fuzzer X-Git-Tag: v242-rc1~166^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0e636bf51aaaf319695f9d0dc91a29b03c8bd69b;p=thirdparty%2Fsystemd.git nspawn: fix memleak uncovered by fuzzer Also use TAKE_PTR as appropriate. --- diff --git a/src/nspawn/nspawn-mount.c b/src/nspawn/nspawn-mount.c index eb0a26ef35b..13f50b2d37b 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; }