diff options
author | Ronny Chevalier <chevalier.ronny@gmail.com> | 2015-06-12 11:37:11 +0200 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2017-03-14 10:01:51 +0100 |
commit | c26ebdc9e7c5729dd2aa08c0cec8d8b1726afcef (patch) | |
tree | 0d6ae474f292790b9874b7a7d28d6d0c271f839a /src/login/logind-user.c | |
parent | 124457a19a42925520f22543b971ff3e98cb2f7c (diff) |
login: fix potential null pointer dereference
Fix CID 1304686: Dereference after null check (FORWARD_NULL)
However, this commit does not fix any bug in logind. It helps to keep
the elect_display_compare() function generic.
Diffstat (limited to 'src/login/logind-user.c')
-rw-r--r-- | src/login/logind-user.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/login/logind-user.c b/src/login/logind-user.c index c0b473930..a9cf529e1 100644 --- a/src/login/logind-user.c +++ b/src/login/logind-user.c @@ -763,6 +763,9 @@ static int elect_display_compare(Session *s1, Session *s2) { * is preferred. * * s1 or s2 may be NULL. */ + if (!s1 && !s2) + return 0; + if ((s1 == NULL) != (s2 == NULL)) return (s1 == NULL) - (s2 == NULL); |