]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nspawn: fix memleak uncovered by fuzzer 11960/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 11 Mar 2019 13:27:29 +0000 (14:27 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 11 Mar 2019 13:29:30 +0000 (14:29 +0100)
Also use TAKE_PTR as appropriate.

src/nspawn/nspawn-mount.c

index eb0a26ef35bf491d935c77312fb142b37b46b67a..13f50b2d37b9cca7f020b2fc4de5e4cdb4a0f8a3 100644 (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;
 }