From 6e0921ddff4dfb17cb50cb01616d736bf118b0f4 Mon Sep 17 00:00:00 2001 From: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com> Date: Fri, 26 May 2023 10:35:26 -0400 Subject: [PATCH] account: check convModule() If client calls some APIs from the account, convModule_ may be un-initialized if the account is not yet ready, causing potential segfaults Change-Id: If47c9d5466e42dee58ea1ebbdd71404ee94a82d1 --- src/jamidht/jamiaccount.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/jamidht/jamiaccount.cpp b/src/jamidht/jamiaccount.cpp index 2a40a7db3e..558de35703 100644 --- a/src/jamidht/jamiaccount.cpp +++ b/src/jamidht/jamiaccount.cpp @@ -2369,7 +2369,9 @@ JamiAccount::connectivityChanged() // nothing to do return; } - convModule()->connectivityChanged(); + + if (auto cm = convModule()) + cm->connectivityChanged(); dht_->connectivityChanged(); { std::lock_guard<std::mutex> lkCM(connManagerMtx_); @@ -4046,7 +4048,8 @@ JamiAccount::monitor() JAMI_DEBUG("[Account {:s}] Monitor connections", getAccountID()); JAMI_DEBUG("[Account {:s}] Using proxy: {:s}", getAccountID(), proxyServerCached_); - convModule()->monitor(); + if (auto cm =convModule()) + cm->monitor(); std::lock_guard<std::mutex> lkCM(connManagerMtx_); if (connectionManager_) connectionManager_->monitor(); -- GitLab