From 4314e58da2b71594a6ad065877c4aa5809657e50 Mon Sep 17 00:00:00 2001 From: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com> Date: Thu, 30 Apr 2015 14:04:15 -0400 Subject: [PATCH] fix crash when account is removed Add protections agains nullptr read access in numbercompletionmodel. Refs #72155 --- src/numbercompletionmodel.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/numbercompletionmodel.cpp b/src/numbercompletionmodel.cpp index 677311d7..7238a16c 100644 --- a/src/numbercompletionmodel.cpp +++ b/src/numbercompletionmodel.cpp @@ -296,8 +296,9 @@ void NumberCompletionModelPrivate::setPrefix(const QString& str) q_ptr->endRemoveRows(); } - for(TemporaryContactMethod* cm : m_hSipIaxTemporaryNumbers) { - cm->setUri(m_Prefix); + for(auto cm : m_hSipIaxTemporaryNumbers) { + if (cm) + cm->setUri(m_Prefix); } if (m_Prefix.protocolHint() == URI::ProtocolHint::RING) { @@ -336,7 +337,8 @@ void NumberCompletionModelPrivate::updateModel() locateNameRange ( m_Prefix, numbers ); locateNumberRange( m_Prefix, numbers ); - for (TemporaryContactMethod* cm : m_hSipIaxTemporaryNumbers) { + for (auto cm : m_hSipIaxTemporaryNumbers) { + if (!cm) continue; const int weight = getWeight(cm->account()); if (weight) { q_ptr->beginInsertRows(QModelIndex(), m_hNumbers.size(), m_hNumbers.size()); -- GitLab