From b9460fdc8b57102b665a662b82efcced4b1af72b Mon Sep 17 00:00:00 2001 From: Ronny Chevalier Date: Fri, 12 Jun 2015 11:37:11 +0200 Subject: 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. --- src/login/logind-user.c | 3 +++ 1 file changed, 3 insertions(+) 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); -- cgit v1.2.3-54-g00ecf