From 6779e8e077db4100996a01700418263048febcaf Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Tue, 21 Feb 2023 14:05:36 +0100 Subject: OmemoManager: Fix deref of nullptr (wrong usage of get_if) My fault. --- src/omemo/QXmppOmemoManager_p.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/omemo') diff --git a/src/omemo/QXmppOmemoManager_p.cpp b/src/omemo/QXmppOmemoManager_p.cpp index 485ef7b4..c6668e19 100644 --- a/src/omemo/QXmppOmemoManager_p.cpp +++ b/src/omemo/QXmppOmemoManager_p.cpp @@ -632,14 +632,17 @@ QXmppTask ManagerPrivate::setUpDeviceId() // 2. There is an empty PubSub node for device bundles: XEP-0030 states that a server must // respond with a node without included items. auto error = std::get_if(&result); - if (auto stanzaErr = error->value()) { - // allow Cancel|ItemNotFound here - if (!(stanzaErr->type() == Error::Cancel && stanzaErr->condition() == Error::ItemNotFound)) { - warning("Existing / Published device IDs could not be retrieved: " % errorToString(*error)); + if (error) { + if (auto stanzaErr = error->value()) { + // allow Cancel|ItemNotFound here + if (!(stanzaErr->type() == Error::Cancel && stanzaErr->condition() == Error::ItemNotFound)) { + warning("Existing / Published device IDs could not be retrieved: " % errorToString(*error)); + return false; + } + // do not return here + } else { return false; } - } else { - return false; } // The first generated device ID can be used if no device bundle node exists. -- cgit v1.2.3