From f2b3e39bcb3942064838cd3d64f7076bcca2b35e Mon Sep 17 00:00:00 2001
From: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
Date: Thu, 14 Mar 2013 17:55:07 -0400
Subject: [PATCH] * #21631: manager: don't answer fake calls

NULL Check calls before trying to answer them
---
 daemon/src/managerimpl.cpp | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp
index a929f1e5d4..9928812b35 100644
--- a/daemon/src/managerimpl.cpp
+++ b/daemon/src/managerimpl.cpp
@@ -325,7 +325,12 @@ bool ManagerImpl::outgoingCall(const std::string& account_id,
 //THREAD=Main : for outgoing Call
 bool ManagerImpl::answerCall(const std::string& call_id)
 {
-    DEBUG("Answer call %s", call_id.c_str());
+    Call *call = getCallFromCallID(call_id);
+
+    if (call == NULL) {
+        ERROR("Call %s is NULL", call_id.c_str());
+        return false;
+    }
 
     // If sflphone is ringing
     stopTone();
@@ -337,11 +342,6 @@ bool ManagerImpl::answerCall(const std::string& call_id)
     // store the current call id
     std::string current_call_id(getCurrentCallId());
 
-    Call *call = getCallFromCallID(call_id);
-
-    if (call == NULL)
-        ERROR("Call is NULL");
-
     // in any cases we have to detach from current communication
     if (hasCurrentCall()) {
 
@@ -359,7 +359,9 @@ bool ManagerImpl::answerCall(const std::string& call_id)
 
     try {
         const std::string account_id = getAccountFromCall(call_id);
-        getAccountLink(account_id)->answer(call);
+        VoIPLink *link = getAccountLink(account_id);
+        if (link)
+            link->answer(call);
     } catch (const std::runtime_error &e) {
         ERROR("%s", e.what());
     }
-- 
GitLab