From f5c5db0753161726c6032178bb10eb41b1ddde02 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Tue, 1 May 2012 17:32:23 -0400 Subject: [PATCH] Fix some warnings and a bug where it went past the length of a vector. Fix a kwstyle warning and an unused variable warning. Also fix a case where it could crash because a vector was referenced passed its end. --- Source/CTest/cmParseCacheCoverage.cxx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Source/CTest/cmParseCacheCoverage.cxx b/Source/CTest/cmParseCacheCoverage.cxx index d2ff4040a..fb8581008 100644 --- a/Source/CTest/cmParseCacheCoverage.cxx +++ b/Source/CTest/cmParseCacheCoverage.cxx @@ -7,8 +7,9 @@ #include -cmParseCacheCoverage::cmParseCacheCoverage(cmCTestCoverageHandlerContainer& cont, - cmCTest* ctest) +cmParseCacheCoverage::cmParseCacheCoverage( + cmCTestCoverageHandlerContainer& cont, + cmCTest* ctest) :cmParseMumpsCoverage(cont, ctest) { } @@ -101,7 +102,6 @@ bool cmParseCacheCoverage::ReadCMCovFile(const char* file) } std::string routine; std::string filepath; - bool foundFile = false; while(cmSystemTools::GetLineFromStream(in, line)) { // clear out line argument vector @@ -181,6 +181,13 @@ bool cmParseCacheCoverage::ReadCMCovFile(const char* file) continue; // skip setting count to avoid crash } // now add to count for linenumber + // for some reason the cache coverage adds extra lines to the + // end of the file in some cases. Since they do not exist, we will + // mark them as non executable + while(linenumber >= coverageVector.size()) + { + coverageVector.push_back(-1); + } coverageVector[linenumber] += count; } return true;