Fixed #6070 (false positive: Array 'array[8192]' accessed at index 8192, which is out of bounds)
This commit is contained in:
parent
eac2d58c9e
commit
b6355b991f
|
@ -698,6 +698,18 @@ void CheckBufferOverrun::checkScope(const Token *tok, const std::vector<std::str
|
|||
|
||||
void CheckBufferOverrun::valueFlowCheckArrayIndex(const Token * const tok, const ArrayInfo &arrayInfo)
|
||||
{
|
||||
// Declaration in global scope?
|
||||
if (tok->scope()->type == Scope::eGlobal)
|
||||
return;
|
||||
/*
|
||||
{
|
||||
const Token *parent = tok->astParent();
|
||||
while (Token::Match(parent, "%var%|::|*|&"))
|
||||
parent = parent->astParent();
|
||||
if (parent && !Token::simpleMatch(parent, "="))
|
||||
return;
|
||||
}
|
||||
*/
|
||||
// Taking address?
|
||||
bool addressOf = false;
|
||||
{
|
||||
|
|
|
@ -2121,6 +2121,10 @@ private:
|
|||
" do_something(&str[0][5]);\n"
|
||||
"}", false, "test.cpp", false);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("class X { static const int x[100]; };\n" // #6070
|
||||
"const int X::x[100] = {0};", false, "test.cpp", false);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void buffer_overrun_1_posix_functions() {
|
||||
|
|
Loading…
Reference in New Issue