summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2021-11-24 05:20:27 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2021-11-24 05:20:27 +0100
commitff502f306c725de368dcc1d7db6ee90b4bd6ee1e (patch)
treee13d93ed9d039d4aa3857da479faa3ea268fbbc7 /src
parentFix loading on Gnome when in flatpak (diff)
downloadnheko-ff502f306c725de368dcc1d7db6ee90b4bd6ee1e.tar.xz
Initialize client lazily
This prevents a use after free in the coeurl logging, if we exit immediately.
Diffstat (limited to 'src')
-rw-r--r--src/MatrixClient.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/MatrixClient.cpp b/src/MatrixClient.cpp

index 2ceb53a8..ea3799b6 100644 --- a/src/MatrixClient.cpp +++ b/src/MatrixClient.cpp
@@ -28,22 +28,20 @@ Q_DECLARE_METATYPE(std::vector<std::string>) Q_DECLARE_METATYPE(std::vector<QString>) Q_DECLARE_METATYPE(std::set<QString>) -namespace { -auto client_ = std::make_shared<mtx::http::Client>(); -} namespace http { mtx::http::Client * client() { + static auto client_ = std::make_shared<mtx::http::Client>(); return client_.get(); } bool is_logged_in() { - return !client_->access_token().empty(); + return !client()->access_token().empty(); } void