From 95b93057a60269acd42af6d99e502dcb75049cd7 Mon Sep 17 00:00:00 2001 From: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com> Date: Thu, 22 Jun 2017 15:40:41 -0400 Subject: [PATCH] BannedContactModel: prevent remove() call with invalid args The application crashes if the ContactMethod given to BannedContactModel::remove() doesn't exist in the banned list. Check for existance and no-op if not. Change-Id: Ifde1c1b9a0c369889c8dabfce20dd8d8937b715b Reviewed-by: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com> --- src/bannedcontactmodel.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bannedcontactmodel.cpp b/src/bannedcontactmodel.cpp index af2b58ee..3950b0a9 100644 --- a/src/bannedcontactmodel.cpp +++ b/src/bannedcontactmodel.cpp @@ -152,6 +152,8 @@ void BannedContactModel::remove(ContactMethod* cm) { auto rowIndex = d_ptr->m_lBanned.indexOf(cm); + if (rowIndex < 0) + return; beginRemoveRows(QModelIndex(), rowIndex, rowIndex); d_ptr->m_lBanned.removeAt(rowIndex); -- GitLab