From bfe598c49fb7c99c93c84b7fcd7ea8ae8bb00739 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Sun, 1 Nov 2020 22:07:05 +0100 Subject: Fixed issue in combineUsingRelations() that could lead to the use of invalid iterators --- src/filedef.cpp | 6 +++++- src/namespacedef.cpp | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/filedef.cpp b/src/filedef.cpp index 9001f62..3279179 100644 --- a/src/filedef.cpp +++ b/src/filedef.cpp @@ -1892,10 +1892,14 @@ void FileDefImpl::combineUsingRelations() { if (m_visited) return; // already done m_visited=TRUE; - for (auto &nd : m_usingDirList) + LinkedRefMap usingDirList = m_usingDirList; + for (auto &nd : usingDirList) { const_cast(nd)->combineUsingRelations(); + } + for (auto &nd : usingDirList) + { // add used namespaces of namespace nd to this namespace for (const auto &und : nd->getUsedNamespaces()) { diff --git a/src/namespacedef.cpp b/src/namespacedef.cpp index 89ca9de..9ff63c2 100644 --- a/src/namespacedef.cpp +++ b/src/namespacedef.cpp @@ -1297,9 +1297,14 @@ void NamespaceDefImpl::combineUsingRelations() { if (m_visited) return; // already done m_visited=TRUE; - for (auto &nd : m_usingDirList) + LinkedRefMap usingDirList = m_usingDirList; + for (auto &nd : usingDirList) { const_cast(nd)->combineUsingRelations(); + } + + for (auto &nd : usingDirList) + { // add used namespaces of namespace nd to this namespace for (const auto &und : nd->getUsedNamespaces()) { -- cgit v0.12