From 9b262bbd66d7fd8cc4cd5b7d47b6d3e8b4dd837e Mon Sep 17 00:00:00 2001 From: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com> Date: Fri, 15 Dec 2017 11:27:11 -0500 Subject: [PATCH] account: fix empty vector access MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NewAccountModelPimpl::slotProfileUpdated() does an access on first element on a vector without checking if it's not empty. This results in immediate crash. Fixed by checking the empty condition and doing nothing in such case. Change-Id: I49276e7ddc7034ebac24d1c109313751f06b4746 Tuleap: #1779 Reviewed-by: Anthony Léonard <anthony.leonard@savoirfairelinux.com> --- src/newaccountmodel.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/newaccountmodel.cpp b/src/newaccountmodel.cpp index b215be38..e28ffe89 100644 --- a/src/newaccountmodel.cpp +++ b/src/newaccountmodel.cpp @@ -206,7 +206,9 @@ NewAccountModelPimpl::slotAccountRemoved(Account* account) void NewAccountModelPimpl::slotProfileUpdated(const Profile* profile) { - emit linked.profileUpdated(profile->accounts().first()->id().toStdString()); + auto& accounts = profile->accounts(); + if (!accounts.empty()) + emit linked.profileUpdated(accounts.first()->id().toStdString()); } } // namespace lrc -- GitLab