]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-login: fix memleak when output argument is NULL 6311/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 8 Jul 2017 22:04:44 +0000 (18:04 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 8 Jul 2017 22:04:44 +0000 (18:04 -0400)
src/libsystemd/sd-login/sd-login.c

index b75acef82c09675f7d9dfb221ba6bed8f1813fdf..d0883eb7270ed227469e290fde5767070f2b5565 100644 (file)
@@ -878,7 +878,8 @@ _public_ int sd_get_uids(uid_t **users) {
 }
 
 _public_ int sd_get_machine_names(char ***machines) {
-        char **l, **a, **b;
+        _cleanup_strv_free_ char **l = NULL;
+        char **a, **b;
         int r;
 
         r = get_files_in_directory("/run/systemd/machines/", &l);
@@ -907,8 +908,10 @@ _public_ int sd_get_machine_names(char ***machines) {
                 *b = NULL;
         }
 
-        if (machines)
+        if (machines) {
                 *machines = l;
+                l = NULL;
+        }
         return r;
 }