From e6e37a4c00788a771a3f155e55631b0f85f166f0 Mon Sep 17 00:00:00 2001 From: Matus Novak Date: Tue, 12 Jan 2021 22:31:57 +0100 Subject: [PATCH] Fix crash when resolving a base or derived class that does not exist in xml input --- src/Doxybook/Node.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Doxybook/Node.cpp b/src/Doxybook/Node.cpp index 01024fb32..370b55ae0 100644 --- a/src/Doxybook/Node.cpp +++ b/src/Doxybook/Node.cpp @@ -368,15 +368,29 @@ void Doxybook2::Node::finalize(const Config& config, if (config.linkLowercase) url = Utils::toLower(url); + const auto findOrNull = [&](const std::string& refId) -> const Node* { + const auto it = cache.find(refid); + if (it == cache.end()) { + return nullptr; + } + return it->second.get(); + }; + for (auto& klass : baseClasses) { if (!klass.refid.empty()) { - klass.ptr = cache.at(klass.refid).get(); + klass.ptr = findOrNull(klass.refid); + if (!klass.ptr) { + klass.refid.clear(); + } } } for (auto& klass : derivedClasses) { if (!klass.refid.empty()) { - klass.ptr = cache.at(klass.refid).get(); + klass.ptr = findOrNull(klass.refid); + if (!klass.ptr) { + klass.refid.clear(); + } } } }