From f8c9b85f4a84c6ede59086b9084e1a0e565644f7 Mon Sep 17 00:00:00 2001
From: Nicolas Jager <nicolas.jager@savoirfairelinux.com>
Date: Fri, 26 May 2017 14:50:00 -0400
Subject: [PATCH] RecentModel: prevent nullptr access

Fix a regression introduced by:
[59f41f8d44: avoid adding entry in RecentModel after an incoming ContactRequest]

This patch check if the pointer is not null before using it.

Change-Id: I49b63f4044bbacc06b36e2c10a3fe7af29100477
Reviewed-by: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com>
---
 src/recentmodel.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/recentmodel.cpp b/src/recentmodel.cpp
index 014ed946..d3d86ec4 100644
--- a/src/recentmodel.cpp
+++ b/src/recentmodel.cpp
@@ -778,7 +778,8 @@ void RecentModelPrivate::slotContactChanged(ContactMethod* contactMethod, const
 
     if (not newPerson
         or /* avoid to add en entry in recent model when a person was built for a contact request */
-        contactMethod->account()->pendingContactRequestModel()->findContactRequestFrom(contactMethod))
+        (contactMethod->account()
+         and contactMethod->account()->pendingContactRequestModel()->findContactRequestFrom(contactMethod)))
         return;
 
     // make sure the Person node exists first, then move any children of the CM nodes
-- 
GitLab