mirror of
https://github.com/Kitware/CMake.git
synced 2026-06-24 08:47:59 +00:00
pvs-studio: (V557) Harden array boundary checks
Tighten array boundary checks to prevent possible overrun.
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
//-V::539
|
||||
# Expression is always true/false.
|
||||
//-V::547
|
||||
# Possible array overrun.
|
||||
# Array underrun/overrun is possible.
|
||||
//-V::557
|
||||
# Part of conditional expression is always true/false.
|
||||
//-V::560
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -93,7 +93,7 @@ void cmStringReplaceHelper::ParseReplaceExpression()
|
||||
this->Replacements.emplace_back(
|
||||
this->ReplaceExpression.substr(l, r - l));
|
||||
} else {
|
||||
if (r != l) {
|
||||
if (r > l) {
|
||||
this->Replacements.emplace_back(
|
||||
this->ReplaceExpression.substr(l, r - l));
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user