Verification; use <uninit> configuration
This commit is contained in:
parent
30b9455e89
commit
f23d880a7e
|
@ -1950,6 +1950,21 @@ void ExprEngine::runChecks(ErrorLogger *errorLogger, const Tokenizer *tokenizer,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Uninitialized function argument..
|
||||||
|
if (settings->library.isuninitargbad(parent->astOperand1(), num) && value.type == ExprEngine::ValueType::ArrayValue) {
|
||||||
|
const ExprEngine::ArrayValue &arrayValue = static_cast<const ExprEngine::ArrayValue &>(value);
|
||||||
|
auto index0 = std::make_shared<ExprEngine::IntRange>("0", 0, 0);
|
||||||
|
for (const auto &v: arrayValue.read(index0)) {
|
||||||
|
if (v.second->isUninit()) {
|
||||||
|
dataBase->addError(tok->linenr());
|
||||||
|
std::list<const Token*> callstack{tok};
|
||||||
|
ErrorLogger::ErrorMessage errmsg(callstack, &tokenizer->list, Severity::SeverityType::error, "verificationUninitArg", "There is function call, cannot determine that " + std::to_string(num) + getOrdinalText(num) + " argument is initialized.", CWE_USE_OF_UNINITIALIZED_VARIABLE, false);
|
||||||
|
errorLogger->reportErr(errmsg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<ExprEngine::Callback> callbacks;
|
std::vector<ExprEngine::Callback> callbacks;
|
||||||
|
|
|
@ -19,6 +19,7 @@ int array2() {
|
||||||
void local1() {
|
void local1() {
|
||||||
int x;
|
int x;
|
||||||
// cppcheck-suppress verificationUninit
|
// cppcheck-suppress verificationUninit
|
||||||
|
// cppcheck-suppress uninitvar
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,3 +28,8 @@ int pointer1(int *p) {
|
||||||
return *p;
|
return *p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pointer2(char *p) {
|
||||||
|
// cppcheck-suppress verificationUninitArg
|
||||||
|
strlen(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue