[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [libringclient] src: fix crash when account is removed
From:       Guillaume Roguez <guillaume.roguez () savoirfairelinux ! com>
Date:       2015-04-30 18:04:24
Message-ID: E1Ynsoy-0007o9-B3 () scm ! kde ! org
[Download RAW message or body]

Git commit 4314e58da2b71594a6ad065877c4aa5809657e50 by Guillaume Roguez.
Committed on 30/04/2015 at 18:04.
Pushed by groguez into branch 'master'.

fix crash when account is removed

Add protections agains nullptr read access in numbercompletionmodel.

Refs #72155

M  +5    -3    src/numbercompletionmodel.cpp

http://commits.kde.org/libringclient/4314e58da2b71594a6ad065877c4aa5809657e50

diff --git a/src/numbercompletionmodel.cpp b/src/numbercompletionmodel.cpp
index 677311d..7238a16 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());
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic