Commit 1c2fed10 authored by Tomi Leppänen's avatar Tomi Leppänen

Check that grp points to something before using it.

parent b6ff3647
......@@ -88,11 +88,15 @@ UserModel::UserModel(QObject *parent)
if (QDBusConnection::systemBus().interface()->isServiceRegistered(UserManagerService))
createInterface();
struct group *grp = getgrnam("users");
for (int i = 0; grp->gr_mem[i] != nullptr; ++i) {
UserInfo user(QString(grp->gr_mem[i]));
if (user.isValid()) { // Skip invalid users here
m_users.append(user);
m_uidsToRows.insert(user.uid(), m_users.count()-1);
if (!grp) {
qCWarning(lcUsersLog) << "Could not read users group:" << strerror(errno);
} else {
for (int i = 0; grp->gr_mem[i] != nullptr; ++i) {
UserInfo user(QString(grp->gr_mem[i]));
if (user.isValid()) { // Skip invalid users here
m_users.append(user);
m_uidsToRows.insert(user.uid(), m_users.count()-1);
}
}
}
// grp must not be free'd
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment