From 9fd18ee8c3facd90da60ff62683693aceb3ff45c Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 10 Jan 2018 22:16:39 +0100 Subject: [PATCH] verify iterators in partialTopologicalSort to be on the safe side currently this can cause a crash because issue 3214 is not fixed yet See also: https://forum.freecadweb.org/viewtopic.php?f=19&t=26295 --- src/App/Document.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/App/Document.cpp b/src/App/Document.cpp index c808d70062..ddfad43c81 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -2303,7 +2303,8 @@ std::vector DocumentP::partialTopologicalSort(const std::v for (auto outListIt : out) { auto outListMapIt = countMap.find(outListIt); - outListMapIt->second.first = outListMapIt->second.first - 1; + if (outListMapIt != countMap.end()) + outListMapIt->second.first = outListMapIt->second.first - 1; } } } @@ -2337,7 +2338,8 @@ std::vector DocumentP::partialTopologicalSort(const std::v for (auto inListIt : in) { auto inListMapIt = countMap.find(inListIt); - inListMapIt->second.second = inListMapIt->second.second - 1; + if (inListMapIt != countMap.end()) + inListMapIt->second.second = inListMapIt->second.second - 1; } } }