diff options
author | Magnus Groß <magnus.gross@rwth-aachen.de> | 2022-10-02 22:23:47 +0200 |
---|---|---|
committer | Magnus Groß <magnus.gross@rwth-aachen.de> | 2022-10-04 11:26:52 +0200 |
commit | 69471d65a44a8634cdee053015d5c86793a5a96e (patch) | |
tree | d120ef146b4cd2f88ca931a6115c7d4c6fe71adb /tools | |
parent | c50da2ff2d54c0251e5ff68361ee3a9822b205a4 (diff) |
qmlls: Avoid access to uninitialized capability
The experimental capability may be uninitialized and store a
std::nullopt, but right now we call isObject() on it regardless.
This will crash immediately when compiled with GLIBCXX_ASSERTIONS
defined.
Fix this by checking for std::nullopt, before calling isObject() on this
std::optional.
Pick-to: 6.4
Change-Id: Ic5f353d586f1187dcbd81f882f59de217d60d089
Reviewed-by: Moody Liu <mooodyhunter@outlook.com>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qmlls/qqmllanguageserver.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/qmlls/qqmllanguageserver.cpp b/tools/qmlls/qqmllanguageserver.cpp index 7621f5bed1..48639f37d2 100644 --- a/tools/qmlls/qqmllanguageserver.cpp +++ b/tools/qmlls/qqmllanguageserver.cpp @@ -88,7 +88,7 @@ void QQmlLanguageServer::setupCapabilities(const QLspSpecification::InitializePa { Q_UNUSED(clientInfo); QJsonObject expCap; - if (serverInfo.capabilities.experimental->isObject()) + if (serverInfo.capabilities.experimental.has_value() && serverInfo.capabilities.experimental->isObject()) expCap = serverInfo.capabilities.experimental->toObject(); expCap.insert(u"addBuildDirs"_s, QJsonObject({ { u"supported"_s, true } })); serverInfo.capabilities.experimental = expCap; |