From 3f427f5aab4328f3543a75d2d25957c0890f26f1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafa=C3=ABl=20Carr=C3=A9?=
 <rafael.carre@savoirfairelinux.com>
Date: Mon, 15 Aug 2011 14:47:54 -0400
Subject: [PATCH] remove call from callmap before terminating it, avoid use
 after free

---
 daemon/src/voiplink.cpp | 11 +++--------
 daemon/src/voiplink.h   |  3 +--
 2 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/daemon/src/voiplink.cpp b/daemon/src/voiplink.cpp
index 8eb60318ac..34e843675d 100644
--- a/daemon/src/voiplink.cpp
+++ b/daemon/src/voiplink.cpp
@@ -55,20 +55,15 @@ bool VoIPLink::addCall (Call* call)
     return false;
 }
 
-bool VoIPLink::removeCall (const std::string& id)
+void VoIPLink::removeCall (const std::string& id)
 {
     ost::MutexLock m (_callMapMutex);
 
-    _debug ("VoipLink: delete call");
-    terminateCall (id);
-
     _debug ("VoipLink: removing call %s from list", id.c_str());
 
-    if (_callMap.erase (id)) {
-        return true;
-    }
+    _callMap.erase (id);
 
-    return false;
+    terminateCall (id);
 }
 
 Call* VoIPLink::getCall (const std::string& id)
diff --git a/daemon/src/voiplink.h b/daemon/src/voiplink.h
index e1a973e261..0a8b945e69 100644
--- a/daemon/src/voiplink.h
+++ b/daemon/src/voiplink.h
@@ -211,9 +211,8 @@ class VoIPLink
 
         /** Remove a call from the call map (protected by mutex)
          * @param id A Call ID
-         * @return bool True if the call was correctly removed
          */
-        bool removeCall (const std::string& id);
+        void removeCall (const std::string& id);
 
         /**
          * Remove all the call from the map
-- 
GitLab