From 1a83e3ef8124cffaa43d900dc4c71b79f7772def Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Tue, 1 Feb 2011 23:02:07 +0200 Subject: [PATCH] Use different way to remove items from vector. The way I was using caused a debug error in Visual Studio 2008. Probably because the iterator got invalidated. So access items as array instead. --- cli/cppcheckexecutor.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index de1756d3f..94deeccfe 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -93,15 +93,12 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c if (!filenames.empty()) { PathMatch matcher(parser.GetIgnoredPaths()); - // Ignore files - std::vector::iterator iter = filenames.end(); - do + std::vector::iterator iterBegin = filenames.begin(); + for (int i = (int)filenames.size() - 1; i >= 0; i--) { - --iter; - if (matcher.Match(*iter)) - filenames.erase(iter); + if (matcher.Match(filenames[i])) + filenames.erase(iterBegin + i); } - while (iter != filenames.begin()); } else {