From 8ecbfcbe318e6f8b65acf9533902292c1f767181 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Tue, 22 Jun 2021 09:43:49 -0400
Subject: [PATCH] jamiaccount: check sip_tr before using it

If the ICE is closed during the cacheSIPConnection, the sip transport
will not be found causing a potential crash

Change-Id: Ic2e7ab9272a2eb3274256151e37c2acd208cb0dd
GitLab: #569
---
 src/jamidht/jamiaccount.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/jamidht/jamiaccount.cpp b/src/jamidht/jamiaccount.cpp
index 0b19db416e..b2920157d3 100644
--- a/src/jamidht/jamiaccount.cpp
+++ b/src/jamidht/jamiaccount.cpp
@@ -4795,6 +4795,10 @@ JamiAccount::cacheSIPConnection(std::shared_ptr<ChannelSocket>&& socket,
         shared->callConnectionClosed(key.second, false);
     };
     auto sip_tr = link_.sipTransportBroker->getChanneledTransport(socket, std::move(onShutdown));
+    if (!sip_tr) {
+        JAMI_ERR() << "No channeled transport found";
+        return;
+    }
     sip_tr->setAccount(shared());
     // Store the connection
     connections.emplace_back(SipConnection {sip_tr, socket});
-- 
GitLab