diff --git a/.pvsconfig b/.pvsconfig index 4d7413f0b4..2cb7888fa0 100644 --- a/.pvsconfig +++ b/.pvsconfig @@ -6,17 +6,13 @@ //-V::508 # The 'x' variable is assigned values twice successively. Perhaps this is a mistake. //-V::519 -# Possible null pointer dereference. -//-V::522 # Constant value is represented by an octal form. //-V::536 # Iterators are passed as arguments to 'Foo' function. Consider inspecting the expression. //-V::539 # Expression is always true/false. //-V::547 -# Expression of the 'A - B > 0' kind will work as 'A != B'. -//-V::555 -# Possible array overrun. +# Array underrun/overrun is possible. //-V::557 # Part of conditional expression is always true/false. //-V::560 @@ -90,8 +86,6 @@ //-V::1071 # Conditional initialization inside the constructor may leave some members uninitialized. //-V::1077 -# Call of the 'Foo' function will lead to buffer underflow. -//-V::1086 # Waiting on condition variable without predicate. A thread can wait indefinitely or experience a spurious wake-up. //-V::1089 # The 'emplace' / 'insert' function call contains potentially dangerous move operation. Moved object can be destroyed even if there is no insertion. diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index 6b465c1512..74089e528a 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -314,9 +314,12 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */) char secondLine[512] = ""; char thirdLine[512] = ""; if (process) { - memset(firstLine, ' ', 68); - memset(secondLine, ' ', 68); - memset(thirdLine, ' ', 68); + std::fill_n(firstLine, 68, ' '); + firstLine[68] = '\0'; + std::fill_n(secondLine, 68, ' '); + secondLine[68] = '\0'; + std::fill_n(thirdLine, 68, ' '); + thirdLine[68] = '\0'; } else { if (this->OkToGenerate) { snprintf(firstLine, sizeof(firstLine), @@ -340,7 +343,8 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */) move(y - 4, 0); char fmt[512] = "Keys: [enter] Edit an entry [d] Delete an entry"; if (process) { - memset(fmt, ' ', 57); + std::fill_n(fmt, 57, ' '); + fmt[57] = '\0'; } printw(fmt_s, fmt); move(y - 3, 0); diff --git a/Source/bindexplib.cxx b/Source/bindexplib.cxx index 59680aa4fd..b43ac0fd1f 100644 --- a/Source/bindexplib.cxx +++ b/Source/bindexplib.cxx @@ -391,7 +391,7 @@ static bool DumpFileWithLlvmNm(std::string const& nmPath, char const* filename, line.c_str()); return false; } - if (line.size() < sym_end + 1) { + if (line.size() < sym_end) { fprintf(stderr, "Couldn't parse llvm-nm output line: %s\n", line.c_str()); return false; diff --git a/Source/cmStringReplaceHelper.cxx b/Source/cmStringReplaceHelper.cxx index 0e1845776e..aa00907435 100644 --- a/Source/cmStringReplaceHelper.cxx +++ b/Source/cmStringReplaceHelper.cxx @@ -93,7 +93,7 @@ void cmStringReplaceHelper::ParseReplaceExpression() this->Replacements.emplace_back( this->ReplaceExpression.substr(l, r - l)); } else { - if (r - l > 0) { + if (r > l) { this->Replacements.emplace_back( this->ReplaceExpression.substr(l, r - l)); } diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 8f79b9f089..ea87266c19 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -3895,7 +3895,8 @@ static cm::optional RemoveRPathELF(std::string const& file, // There is no RPATH or RUNPATH anyway. return true; } - if (se_count == 2 && se[1]->IndexInSection < se[0]->IndexInSection) { + if (se_count == 2 && se[0] && se[1] && + se[1]->IndexInSection < se[0]->IndexInSection) { std::swap(se[0], se[1]); } diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx index 960e36cf40..aa3975f316 100644 --- a/Source/cmTargetPropCommandBase.cxx +++ b/Source/cmTargetPropCommandBase.cxx @@ -81,14 +81,16 @@ bool cmTargetPropCommandBase::HandleArguments( } bool prepend = false; - if ((flags & PROCESS_BEFORE) && args[argIndex] == "BEFORE") { + if ((flags & PROCESS_BEFORE) && argIndex < args.size() && + args[argIndex] == "BEFORE") { if (args.size() < 3) { this->SetError("called with incorrect number of arguments"); return false; } prepend = true; ++argIndex; - } else if ((flags & PROCESS_AFTER) && args[argIndex] == "AFTER") { + } else if ((flags & PROCESS_AFTER) && argIndex < args.size() && + args[argIndex] == "AFTER") { if (args.size() < 3) { this->SetError("called with incorrect number of arguments"); return false; @@ -97,7 +99,8 @@ bool cmTargetPropCommandBase::HandleArguments( ++argIndex; } - if ((flags & PROCESS_REUSE_FROM) && args[argIndex] == "REUSE_FROM") { + if ((flags & PROCESS_REUSE_FROM) && argIndex < args.size() && + args[argIndex] == "REUSE_FROM") { if (args.size() != 3) { this->SetError("called with incorrect number of arguments"); return false; diff --git a/Tests/CMakeLib/testUVStreambuf.cxx b/Tests/CMakeLib/testUVStreambuf.cxx index a901ab2ad2..54a65c8280 100644 --- a/Tests/CMakeLib/testUVStreambuf.cxx +++ b/Tests/CMakeLib/testUVStreambuf.cxx @@ -246,7 +246,8 @@ static bool testUVStreambufRead( << std::endl; goto end; } - if (std::memcmp(inputData.data(), outputData, 64)) { + if (std::memcmp(inputData.data(), outputData, //-V1086 Ignore underflow + 64)) { std::cout << "Read data does not match write data" << std::endl; goto end; }