From 964806347bb32ce041a1d61f4b601e5a148d45bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sat, 8 Jul 2017 18:04:44 -0400 Subject: [PATCH] sd-login: fix memleak when output argument is NULL --- src/libsystemd/sd-login/sd-login.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libsystemd/sd-login/sd-login.c b/src/libsystemd/sd-login/sd-login.c index b75acef82c0..d0883eb7270 100644 --- a/src/libsystemd/sd-login/sd-login.c +++ b/src/libsystemd/sd-login/sd-login.c @@ -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; }