]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lslogins: fix possible memory leak [coverity scan]
authorKarel Zak <kzak@redhat.com>
Wed, 11 Oct 2017 13:13:44 +0000 (15:13 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 11 Oct 2017 13:13:44 +0000 (15:13 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/lslogins.c

index 5d896d73c03a538c3eb1e95af25000c81d0c75cd..1042b9b41ceb849f018350f77bd67d7cb9a43b8e 100644 (file)
@@ -606,12 +606,12 @@ static struct lslogins_user *get_user_info(struct lslogins_control *ctl, const c
                return NULL;
        }
 
-       user = xcalloc(1, sizeof(struct lslogins_user));
-
        grp = getgrgid(pwd->pw_gid);
        if (!grp)
                return NULL;
 
+       user = xcalloc(1, sizeof(struct lslogins_user));
+
        if (ctl->wtmp)
                user_wtmp = get_last_wtmp(ctl, pwd->pw_name);
        if (ctl->btmp)