summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonny Chevalier <chevalier.ronny@gmail.com>2015-06-12 11:37:11 +0200
committerRonny Chevalier <chevalier.ronny@gmail.com>2015-06-15 10:22:32 +0200
commitb9460fdc8b57102b665a662b82efcced4b1af72b (patch)
treefea61270f6c232f60e7a5f5fd2c9dc56eae8d628
parenteb59b6094197a7dcef89639ec3e91eef61b639bb (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.
-rw-r--r--src/login/logind-user.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/login/logind-user.c b/src/login/logind-user.c
index c0b473930d..a9cf529e12 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);