From 3611f7cbdcc1a9c96a542d40a439712cf5c3818a Mon Sep 17 00:00:00 2001
From: Tobias Markmann <tm@ayena.de>
Date: Thu, 30 Mar 2017 15:30:06 +0200
Subject: Fix access to potential unavailable page in QtUserSearchWindow
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Adding searched JIDs to the list of JIDs only makes sense
for cases where there is a multi JID page in the first place.

Coverity raised this issue.

Test-Information:

All unit tests pass on macOS 10.12.4 and the “Add Contact”
and “Start Chat” dialogs using a user search still work.

Change-Id: Icde63f13a2f83690b3189a9c91237eadd6b5218b

diff --git a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
index cf62540..7575a13 100644
--- a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
+++ b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2017 Isode Limited.
  * All rights reserved.
  * See the COPYING file for more information.
  */
@@ -81,7 +81,7 @@ void QtUserSearchWindow::handleCurrentChanged(int page) {
         firstMultiJIDPage_->reset();
     }
     resultsPage_->emitCompletenessCheck();
-    if (page == 1 && lastPage_ == 3) {
+    if (firstMultiJIDPage_ && page == 1 && lastPage_ == 3) {
         addSearchedJIDToList(getContact());
         setSecondPage();
     }
-- 
cgit v0.10.2-6-g49f6